Sync an external database with SQLIte database on application start
I have an SQLite database for my Android app that stores a copy of some data from another database on a server. When the user opens the app, I want to sync the local copy to the external master. The user may have been on the related website and inserted/updated/deleted data.
If it was just insert/update, timestamps could be used, but as they could delete data, I'm not sure how to go about checking for deleted rows.
So, what's the开发者_运维知识库 best way to tell what's changed and update the local copy?
I'd add a table to audit the deletes (containing key fields of the deleted records) and transfer that on sync, and after a successful sync clear the table down.
Hm, we are working on iOS project, which will sync it's database with server if server will respond what it have newer version. Our server incrementally stores performed SQL and on request if compounds all those changes to specific date and gziped sends to the application, where my Objective-C wrapper execute SQL statement from downloaded file.
May be same approach will be good for you too.
精彩评论