Retrieving the Phone number from a contact using "ContactsContract" by an ID?

722 Views Asked by At

I'm able to retrieve the display name of contact using the id Code as follows:

Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, selectedid);
Cursor cur = managedQuery(uri, null, null, null, null);
startManagingCursor(cur);
cur.moveToNext();
String mname = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));

Where the "selectedid" is my id of the contact to be retrieved. Now i have a problem in retrieving the phone number from that id.

If possible can u type me the code which i have to add to get the phone number from that id

2

There are 2 best solutions below

0
On BEST ANSWER

i kind of figured it out .... try the link bellow...

Retrieve Contact Phone Number From URI in Android

1
On

Have you tried:

String number = cur.getString(cur.getColumnIndex(
    ContactsContract.CommonDataKinds.Phone.NUMBER));