Your query says: "update _all_ data rows for this contact, setting one of the fields to "John" and another to "Abraham". Data rows include phone numbers, emails, photos, you-name-it. What you need to do is find a specific data row you want to update and then use its _id in the selection (or, more commonly, in the URI itself).
Cheers, - Dmitri On Tue, May 4, 2010 at 6:46 AM, JKDESAI <jk.shona17...@gmail.com> wrote: > > > On Apr 19, 2:41 pm, Timo Prill <timo.pr...@googlemail.com> wrote: > > hi all, > > > > i got a problemupdatingacontact'sdetails. > > i use the following code to update thecontactname: > > "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, thecontactname 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 > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > > For more options, visit this group athttp:// > groups.google.com/group/android-developers?hl=en > > Hi, > > I have used your code snippet for updating contact details with API > 2.0. > > But using that, display name is updated successfully, but it deletes > all the other information like phone number and email. > > Can you tell me why it happens?..or I am missing something... > > Here Data used is "android.provider.ContactsContract.Data". > > The same code I have used is as below: > > ArrayList<ContentProviderOperation> > operations = > new > ArrayList<ContentProviderOperation>(); > > > operations.add(ContentProviderOperation.newUpdate( > > ContactsContract.Data.CONTENT_URI).withSelection( > Data.CONTACT_ID + "=?", new String[] > { id }).withValue( > StructuredName.GIVEN_NAME, "John").withValue( > StructuredName.FAMILY_NAME, > "Abraham").build()); > > try { > > getContentResolver().applyBatch(ContactsContract.AUTHORITY, > operations); > } catch (RemoteException e) { > System.out.println("Exception : " + > e.getMessage()); > e.printStackTrace(); > } catch (OperationApplicationException e) { > System.out.println("Exception : " + > e.getMessage()); > e.printStackTrace(); > } > > Please share your thoughts. > > -- > 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<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