I have a relatively small Table in a SQL database in my Android app (around 15 or 20 rows). Every so often I want to be able to do a complete re-sync of the database with an online JSON file, so that:
- Rows in the JSON file that are not in the database are added
- Rows in the JSON file and in the database are updated
- Rows in the database that are not in the JSON file are deleted
What's the b开发者_如何学JAVAest way to do something like this?
1 & 2 are quite easy, use Insert or Replace statement. The third one there's no real easy way to do that short of getting all the id's from the database then removing all the id's from the json file, then running deletes on the id's you have left.
精彩评论