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

  • Home
  • SEARCH
  • 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 3693756
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:24:53+00:00 2026-05-19T04:24:53+00:00

my code is as following String projection[] = new String[]{ ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; Cursor

  • 0

my code is as following

String projection[] = new String[]{ ContactsContract.Contacts._ID,
                                            ContactsContract.Contacts.DISPLAY_NAME };
        Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, //The URI, using the content:// scheme, for the content to retrieve.
                        projection,             // projection
                        null,               // selection
                        null,               // selectionArgs
                        ContactsContract.Data.DISPLAY_NAME + " COLLATE LOCALIZED ASC");

I want to add contact id, name and number (MAIN or any one of type) to intent, but problem is that I am unable to access Name. And another problem is that for each contact id returns “-1”. why?
Is there any solution?

  • 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-19T04:24:54+00:00Added an answer on May 19, 2026 at 4:24 am

    Instead off supplying the value of projection variable as null in the query method you should try it like this:

    String[] projection = new String[] {ContactsContract.Data._ID,
                                        ContactsContract.Data.CONTACT_ID,
                                        ContactsContract.Data.DISPLAY_NAME};
    

    It is clearly written in Android Developer Documentation that:

    Adapter that exposes data from a Cursor to a ListView widget. The Cursor must include a column named “_id” or this class will not work.

    See here in the documentation:

    http://developer.android.com/reference/android/widget/CursorAdapter.html

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

Sidebar

Related Questions

I have following code in pre-Android2.0 API: String[] PROJECTION = new String[] { Contacts.People._ID,
I can load a list with the following code String[] projection = new String[]
I have the following code: String inputFile = somefile.txt; FileInputStream in = new FileInputStream(inputFile);
The following Code does not compile Dim BasicGroups As String() = New String() {Node1,
Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something
currently I have the following code: String select = qry.substring(select .length(),qry2.indexOf( from )); String[]
I have a C# application that includes the following code: string file = relativePath.txt;
I'm trying to get the following code working: string url = String.Format(@SOMEURL); string user
I am trying to compile the following code: private String dataToString(){ Map data =
The following code receives seg fault on line 2: char *str = string; str[0]

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.