0

I'm trying to build an application where my contacts are merged with the phone contacts (similar, as Google, Facebook, LinkedIn).

I built the sync adapter and I added automatically into accounts. I also have a content provider with a table of contacts. I followed the following topic How to make a custom account show up like Google/LinkedIn/Facebook in the native Contacts app?.

So, I have my own uri and table of contacts. From here I don't know how to link the items from my table with the phone contacts

Community
  • 1
  • 1
Colateral
  • 1,736
  • 2
  • 18
  • 22

1 Answers1

0

After reading many other discussions simply I need to:

    Uri myUri = uri.buildUpon().appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER,"true").build();

    ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();

    ops.add(ContentProviderOperation.newInsert(uri)
            .withValue(RawContacts.ACCOUNT_NAME, ACCOUNT_NAME)
            .withValue(RawContacts.ACCOUNT_TYPE, ACCOUNT_TYPE)
            //.withValue(RawContacts.SOURCE_ID, 12345)
            //.withValue(RawContacts.AGGREGATION_MODE, RawContacts.AGGREGATION_MODE_DISABLED)
            .build());

    resolver.applyBatch(ContactsContract.AUTHORITY, ops);
Akil
  • 719
  • 13
  • 23
Colateral
  • 1,736
  • 2
  • 18
  • 22