2

Can any one tell me how can we add the contact number in existing contact having same contact_TYPE in android using ContentProviderOperation. I tried many this but didn't get any solution yet.

Anjali Tunge
  • 139
  • 1
  • 5

1 Answers1

0

I got solution for this problem, I just have to add the same display_name of the contact in which I want to link the details. And then do the normal insertion method.

  ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
              .withValue(RawContacts.ACCOUNT_TYPE, null)
              .withValue(RawContacts.ACCOUNT_NAME, null)
              .build());
                          ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
                .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, rawContactID)
                .withValue(ContactsContract.Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
                .withValue(StructuredName.DISPLAY_NAME, "Display_Name of selected contact")
                .build());
Anjali Tunge
  • 139
  • 1
  • 5