Thanks for your replay.

Here is the scenario I am following.

First of all, I am getting a curser for the Contact at some particular
Id using this:

contactCursor =
getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
null,
                                ContactsContract.Contacts._ID + " = ?",
                                new String[]{id}, null);

Now  I need to update the GIVEN_NAME and FAMILY_NAME  of this contact.

For that, What Id I have to pass in the withSelection(String,
String[]) method along with Data.CONTACT_ID ?

I have tried by getting RAW_DATA_ID but no success.

Please help me.

On May 5, 9:53 pm, Dmitri Plotnikov <[email protected]> wrote:
> 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 <[email protected]> wrote:
>
> > On Apr 19, 2:41 pm, Timo Prill <[email protected]> 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 [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<android-developers%[email protected]>
> > > 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 [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<android-developers%[email protected]>
> > 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to