Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 904723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:05:59+00:00 2026-05-15T16:05:59+00:00

My Android app needs to retrieve information about a contact (namely, phone number and

  • 0

My Android app needs to retrieve information about a contact (namely, phone number and name.) I wrote some code using getContentResolver().query() In the results, I am seeing that the name is being returned, and other information like when I last contacted that person, but not the phone number. What am I doing wrong?

The code:

Log.w("MyApp", "requesting " + phonesUri.toString());
Cursor contactCursor = context.getContentResolver().query(person, null, null, null, null);
contactCursor.moveToFirst();

for (int i = 0; i < contactCursor.getColumnCount(); i ++) {
   Log.w("MyApp", contactCursor.getColumnName(i) + ": " + contactCursor.getString(i));
}

which outputs this:

W/MyApp (21477): requesting content://contacts/people/169/phones
W/MyApp (21477): times_contacted: 6
W/MyApp (21477): custom_ringtone: null
W/MyApp (21477): primary_organization: null
W/MyApp (21477): phonetic_name: 
W/MyApp (21477): status: null
W/MyApp (21477): label: null
W/MyApp (21477): number: null
W/MyApp (21477): type: null
W/MyApp (21477): mode: null
W/MyApp (21477): last_time_contacted: 1278113641980
W/MyApp (21477): display_name: (name removed for privacy)
W/MyApp (21477): im_handle: null
W/MyApp (21477): _id: 169
W/MyApp (21477): number_key: null
W/MyApp (21477): starred: 0
W/MyApp (21477): primary_email: null
W/MyApp (21477): name: (name removed for privacy)
W/MyApp (21477): primary_phone: null
W/MyApp (21477): im_account: null
W/MyApp (21477): notes: 
W/MyApp (21477): im_protocol: null
W/MyApp (21477): send_to_voicemail: 0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:06:00+00:00Added an answer on May 15, 2026 at 4:06 pm
    1. You don’t need to write your own iterate method to print to screen/log, call DatabaseUtils.dumpCursorToString(cursor); on a cursor to get a String representation of the raw output.

    2. Phone numbers are stored in their own table and need to be queried separately. To query the phone number table use the URI stored in the SDK variable ContactsContract.CommonDataKinds.Phone.CONTENT_URI. Use a WHERE conditional to get the phone numbers for the specified contact.

          if (Integer.parseInt(cur.getString(
                 cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
              Cursor pCur = cr.query(
          ContactsContract.CommonDataKinds.Phone.CONTENT_URI, 
          null, 
          ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", 
          new String[]{id}, null);
          while (pCur.moveToNext()) {
          // Do something with phones
          } 
          pCur.close();
      }
      

    Perform a second query against the Android contacts SQLite database. The phone numbers are queried against the URI stored in ContactsContract.CommonDataKinds.Phone.CONTENT_URI. The contact ID is stored in the phone table as ContactsContract.CommonDataKinds.Phone.CONTACT_ID and the WHERE clause is used to limit the data returned.

    Check out this tutorial Working With Android Contacts

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android app which needs to be signed using a specific keystore
I've written an Android app that needs the short timezone name in which the
I'am developing an application for android, which needs network in order to retrieve some
My Android app needs to populate the ListView using the data from an ArrayList
I have a working android app using TextView, some formatting (line breaks, rows of
I am developing an android app which needs to activate the GPS. I read
I'm writing an Android app that needs to access GMail, and I'd like to
So I'm writing an android app that needs to grab book price data from
I am developing an app for android where I need some data from a
im building an android app and i need to save some files locally on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.