Reputation: 119
I have a SQLite database on Android, which I'm designing to be available offline, and is getting data through a REST API on the server side. But is there any way I can only get the data that has changed since last upload? For example, if there is 5 customers registered in the MySQL database, and one of them change the address, then I only want to update the one with new address, and not the other 4.
Upvotes: 1
Views: 1411
Reputation: 774
Using timestamp field will be a solution for downloading incremental changes from the server to the client. For uploading data from the client to the server - some "Dirty" flag can be used to designate new records for upload.
Have a look at this question: Client-server synchronization over REST, which addresses the similar problems.
Upvotes: 2
Reputation: 14226
There is no build in API.
However you can create a timestamp column for every table which gets set on every update and insert.
When syncing, you can ask the server to give you only the rows with a timestamp greater than the last sync.
You might get in trouble when doing updates in both directions.
Upvotes: 1