6

My app "syncs" all the contacts on a phone with the server. However, part of the requirement is that if any contact is inserted, updated, or deleted then the sync must happen again to maintain data integrity. I know about registering a ContentObserver on ContactsContract.Contacts.CONTENT_URI, but any such observer would have to be unregistered on the Activity's onPause(), and thus would not get notifications if the app wasn't running at that moment.

I also do not want to implement a content observer in a service, since services aren't permanent either. Plus, I don't like the idea of running something in the background 24x7.

So, is there any way by which I can detect that the contacts have changed since a sync? I do not need a real-time notification, so it's ok if this detection only happens when the app is run next.

Anuj Jain
  • 315
  • 1
  • 15
  • Found any solution to this yet? – Magnus Mar 08 '14 at 17:24
  • Nope, nothing. I ended up periodically computing a hash of all current contacts (when the phone is connected to a charger), and comparing it to the previous stored hash. If the two hashes mismatch, then I perform the sync again. – Anuj Jain Mar 10 '14 at 01:05
  • I encountered in the same issue and did a similar solution. Did you found any solution?? – Nativ Jun 19 '14 at 15:12

0 Answers0