0

I am working on an app that syncs device contacts with a server and I stumbled across this situation.

Sim card contacts are not being aggregated with the rest of them so every time a sync is performed, the syncAdapter finds them as a new contact and sends them to the server.

On my android device, (s5 - 5.0), in the Phone app, you can import contacts from sim to different accounts, but they will appear as duplicates. So clearly they have a special situation.

How could I avoid back-to-back syncing without avoiding the sim contacts?

DoruChidean
  • 7,941
  • 1
  • 29
  • 33

1 Answers1

0

You can manage something like this.

  1. Create a hashset & add all phone numbers into it which you have synced very first time & convert it to json string & save into shared preferences. Next time again when app go for sync contacts to server before this get back the json string from shared preferences & convert that in to hashset & check the phone number is exist or not in the hashset.
  2. Manage all contacts on server side, get all phone numbers of a particular user into an array by select query, before saving the contacts into the Database check weather phone number exist or not in the numbers array, if not then insert it into the Database.
Virender
  • 168
  • 10
  • The contacts can be in great number, so shared prefs is useless, also, using a hashmap during sync will affect performance and also the phone number should never be used as unique identification – DoruChidean Jul 14 '16 at 13:21