1

How can I query Android contact (in android 2.1) based on a phone number?

I used to use People.CONTENT_URI (before android 2.1) but that is now deprecated.

Thank you.

michael
  • 106,540
  • 116
  • 246
  • 346
  • More good examples here: http://stackoverflow.com/questions/3079365/android-retrieve-contact-name-from-phone-number/8695649 – mdaddy Jan 01 '12 at 21:59

1 Answers1

1

Quick way to lookup a contact using just the phone number. This is how the caller ID does it.

Uri uri = Uri.withAppendedPath(
    PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
managedQuery(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
Robby Pond
  • 73,164
  • 16
  • 126
  • 119
  • Where can I find code? I would like to know what is the '...' in the above code? Thank you. – michael Jul 08 '10 at 18:24
  • 2
    That's just an example. managedQuery(uri, new String[]{PhoneLookup.DISPLAY_NAME}, null, null, null, null); would only return the display name. – Robby Pond Jul 08 '10 at 18:48