开发者

Android Update SQL Database Contents

开发者 https://www.devze.com 2023-03-12 16:19 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消