sqlite - Android delete all rows or update and remove old? -


i need store list of contacts web server in android app. android data copy of web server , contacts have no foreign keys , table. i'm thinking of updating android data on periodic basis. i'm wondering method best update data, i'm thinking of:

  1. delete rows table , insert data web server
  2. update rows match webserver , delete weren't updated.

which method better in terms of performance?

this have done before when working on project:

  • first, truncating entire table , doing fresh storage database in app depends on size of data syncing down. obviously, fine delete if size small.
  • the solution used have column in remote server (corresponding table) when contact item deleted, update deleted timestamp or [deleted].
  • when syncing down phone, check see sync items not deleted or updated/new.or
  • sync down contacts json field [deleted : true] once in android code, check see if [deleted == true] , consequently delete contact item local db. loop through list store new items.
  • that means pulling down new or updated items , non-modified items not unnecessarily touched. reduces amount of transactions have do.

good luck , hope helps.


Popular posts from this blog