1

I'm working on a function to upload contacts to server if there's any change to the contact book. One approach I found is querying the DATA_VERSION column of ContactsContract.Data and save version for each contact to app specific shared preference, later on requery the table and check if there's any version mismatch.

But this is apparently too heavy as all I need is just a Boolean whether the entire contacts book is touched.

Note I can't do this through ContentObserver because the address book might be changed when app is not running.

Is there someway to generate a check sum for the entire address book and check later?

mehrdad khosravi
  • 2,228
  • 9
  • 29
  • 34
Arrow Cen
  • 733
  • 1
  • 8
  • 22
  • You should see this: http://stackoverflow.com/questions/5733775/broadcast-on-contact-add-change – Eric B. Nov 03 '15 at 05:22
  • @eric247 that one doesn't solve the problem, the dirty field gets cleared after the account is synced, which happens a couple of minutes after a contact is modified. While I need to check if the current contact book is different from previous one(which might be touched a couple of days ago). – Arrow Cen Nov 03 '15 at 18:37

1 Answers1

0

Well I think I'll answer the question myself. I ended up just querying Data.CONTACT_LAST_UPDATED_TIMESTAMP and save the latest time in a shared preference. Next time just query the table with entries with time later than saved time. This might potentially go through the entire table again but is definitely faster and more efficient than buffering all versions

Arrow Cen
  • 733
  • 1
  • 8
  • 22