12

I have an SQLite database on Android and a MySQL database on a server. I want to synchronize these databases when a user edits data on their phone or edits data on a website.

I know how to update the MySQL database on the server when a user makes changes on their phone but I don't know how to update the Android database when a user makes changes on the website.

I have read into push notification and believe this to be a good path to follow but I have a few questions about it:

  1. When a user updates data through a website it will send a push notification to that user's phone saying changes have been made. Can this push notification trigger to update the Android's database with the new changes made on the Server database?

  2. What if a user turns off push notifications? Will I still be able to trigger for their Android database to be updated?

I have also read up on SQLite and MySQL database synchronization and found this post SQLite and MySQL sync but did not find the post helpful for my situation.

Are push notifications a good way to go or should I be using a different approach?

In a nutshell - I want a way for the Android device to detect changes on the MySQL database and update its SQLite database without the user initiating the synchronization.

Community
  • 1
  • 1
Gary Holiday
  • 2,947
  • 2
  • 25
  • 67

1 Answers1

0

I'm afraid I've not used push notifications. But a solution might be: You could create an early method call to an Asynchronous polling event from the launcher onCreate() that looks up the server to see if any changes have been registered (though an API of some sort) in the MySQL, and then update the SQLite that way? Since it's the first thing that happens on launch, technically the user isn't initiating it. Granted this won't update during use of the app, unless you repeat poll at regular intervals?

iaindownie
  • 1,046
  • 10
  • 28