如何使用ContentProviderOperation android在Android中具有相同contact_TYPE的现有联系人中添加联系号码

时间:2021-09-30 08:21:26

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.

任何人都可以告诉我如何在Android中使用ContentProviderOperation在具有相同contact_TYPE的现有联系人中添加联系号码。我尝试了很多这个,但还没有得到任何解决方案。

1 个解决方案

#1


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.

我得到了这个问题的解决方案,我只需添加联系人的相同display_name,我想在其中链接详细信息。然后做正常的插入方法。

  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());

#1


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.

我得到了这个问题的解决方案,我只需添加联系人的相同display_name,我想在其中链接详细信息。然后做正常的插入方法。

  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());