kAnNaN
kAnNaN

Reputation: 3679

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

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

Upvotes: 1

Views: 711

Answers (2)

kAnNaN
kAnNaN

Reputation: 3679

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

Retrieve Contact Phone Number From URI in Android

Upvotes: 0

Sebastian Roth
Sebastian Roth

Reputation: 11537

Have you tried:

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

Upvotes: 1

Related Questions