Friday, November 19, 2010

[android-developers] Re: Update information in contacts

This wont wont as the first parameter URI is incorrect.
You need to use ContactsContract.CommonDataKinds.Phone.CONTENT_URI
there for adding a number.
For the matter of fact even the generic URI for adding any contact
detail info will also work i.e Data.CONTENT_URI.

On Nov 18, 11:54 pm, vnv <nikola1...@gmail.com> wrote:
> Hi,
>
> I am trying to update information inContactsdatabase, phonenumber.
>
> Analyzing following code:
>
>         public ArrayList<Phone> getPhoneNumbers(String id) {
>                 ArrayList<Phone> phones = new ArrayList<Phone>();
>
>                 Cursor pCur = this.cr.query(
>                                 ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
>                                 null,
>                                 ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
>                                 new String[]{id}, null);
>                 while (pCur.moveToNext()) {
>                         phones.add(new Phone(
>
> pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.N UMBER))
>                                         ,
> pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.T YPE))
>                         ));
>
>                 }
>                 pCur.close();
>                 return(phones);
>         }
>
> I am trying to update info about record with id=1:
>
> Doc says that I could use getContentResolver.update();
>
> So I want to use it like
>
> ContentResolver cr = getContentResolver();
> final ContentValues values = new ContentValues();
> values.put(ContactsContract.CommonDataKinds.Phone.NUMBER, "55555555");
>
> cr.update(ContactsContract.Contacts.CONTENT_URI, values, where,
> selectionArgs);
>
> Will this work and how to configure where and selectionArgs properly
> for doing this if it works?

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate