yeah, you are right, i was totally confused...
already found the error myself some time later..
i mixed up contact ID and data-row ID..
volcano-ash seemed to influence me this morning ;)

it now updates correctly using:

oerations.add(ContentProviderOperation.newUpdate(
                    ContactsContract.Data.CONTENT_URI).withSelection(
                    Data.CONTACT_ID + "=?", new String[] { id }).withValue(
                    StructuredName.GIVEN_NAME, firstName)
.withValue(StructuredName.FAMILY_NAME, lastName).build());

but thx anyway for your reply! stupid-me! :)
cheers
timo


Am 19.04.2010 16:01, schrieb Dmitri Plotnikov:

What's the _id here? It should be the data row id, not the contact id. Also, you shouldn't specify the mime type in an update statement - it is not updatable.

Cheers,
Dmitri

On Apr 19, 2010 2:44 AM, "Timo Prill" <timo.pr...@googlemail.com <mailto:timo.pr...@googlemail.com>> wrote:
> hi all,
>
> i got a problem updating a contact's details.
> i use the following code to update the contact name:
> "operations" is a ArrayList of ContentProviderOperation.
>
>
> operations.add(ContentProviderOperation.newUpdate(
> ContactsContract.Data.CONTENT_URI)
> .withSelection(Data._ID + "=?", new String[]{id})
>
> .withValue(Data.MIMETYPE,StructuredName.CONTENT_ITEM_TYPE)
> .withValue(StructuredName.GIVEN_NAME, firstName)
> .withValue(StructuredName.FAMILY_NAME, lastName)
> .build());
>
> contentResolver.applyBatch(ContactsContract.AUTHORITY, operations);
>
>
> but after this query, the contact name is not updated.. (at least the
> name did not change in the phone's addressbook)
> i cant figure out why...what am i doing wrong? must be a simple thing i
> am missing..
>
> thanks in advance
> timo
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com <mailto:android-developers@googlegroups.com>
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com <mailto:android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to