Updating sqlite database while updating server database

I am working on updating a database on a mobile device using SQLITE db, which should be updated as the database server updates on the wamp server.
Can anyone suggest me any ideas on how to achieve this. I do not want to read the entire server database, as this will increase the use of data when reading the entire database for only one update or for several updates. The update is performed in the product table, and only the price field is updated on the server side.

+8
android
source share
1 answer

You can define a service in your application that periodically asks if there is updated data on your db server. On the server side, you can implement a web service that will receive a json object in which the current date will be placed, the name of the table you want to check for updates, and other information based on your goals. I’ll better explain an example: 1) when the application starts, the background service will also start. This service will request (for example, every 3 minutes) your web service to find out if there are new updates for the specified table. 2) The webservice will get the name of the table you want to check, and the date-time, preferably in the unix timestamp. For example, you want to see if there are new entries for the "products" table after 2012-08-20 22:00:00. You can create a json object and an http request with this information in your application and transfer it to the server. 3) Your web service will respond to you by providing a json array with all the data that will be added or changed after 2012-08-20 22:00:00. Of course, you should store this information on the db server (basically, each record will have a field with the time of the first insertion / last modification)
4) Then you can update the local sqlite database.

This is probably not very effective, but it works.

Andrea

+6
source share

All Articles