Android - Update a contact

前端 未结 3 394
我寻月下人不归
我寻月下人不归 2020-12-01 05:30

I\'m trying to update a contact of my phone book directly from my app. I\'m able to add and delete the contacts but the update just does nothing!

After the insert or

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 06:22

    I am not sure if this helps you, however I found a blog about the difference between contact_id and raw_contact_id:

    http://android-contact-id-vs-raw-contact-id.blogspot.de/

    In this blog he explains well how the contacts api works and if i understand it correctly you have to use the raw_contact_id to change your entry. So forget the contact_id for update and change your update so that the raw_contact_id entry is changed. I would roughly guess it would look something like this :

    ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
    .withSelection(RawContacts._ID + "=?", new String[]{entertheraw_contact_id})
    .withValue(StructuredName.DISPLAY_NAME, "Lost Symbol Characters")
    .build());
    getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
    

    I hope this helps you a bit and thank you again for your help form before.

提交回复
热议问题