0

I want to read a particular contact from contacts,say "john", and to display all phone numbers in that particular contact( work,mobile,home). Can anyone help me out with this.

roshanK
  • 409
  • 4
  • 10
  • 19
  • It's a little bit more complicated that you may think since you need to query the address book. What data do you know about "john"? How will you know if it's one "john" or the next "john" – Juan Cortés May 10 '12 at 16:37
  • if there are more john then cursor would return more results set ryt – roshanK May 10 '12 at 16:58
  • see this links .it will help you to fetch particular contacts. http://stackoverflow.com/questions/3370628/retrieve-contact-phone-number-from-uri-in-android http://stackoverflow.com/questions/4301064/how-to-get-the-firstname-and-lastname-from-android-contacts http://stackoverflow.com/questions/6108482/retriving-group-of-particular-contact http://stackoverflow.com/questions/8352961/how-to-get-contact-name-details-for-a-particular-contact – Ronak Mehta May 10 '12 at 18:00

1 Answers1

0

This also might help:

http://developer.android.com/reference/android/provider/ContactsContract.Data.html

See the query section; it has this code:

Finding all Data of a given type for a given contact

Cursor c = getContentResolver().query(Data.CONTENT_URI,
      new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
      Data.CONTACT_ID + "=?" + " AND "
              + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
      new String[] {String.valueOf(contactId)}, null);
robertly
  • 2,132
  • 14
  • 9