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 7763845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:45:42+00:00 2026-06-01T14:45:42+00:00

I have a code from where I can get the contacts name in a

  • 0

I have a code from where I can get the contacts name in a auto complete text view, here is my code

autoContacts=(AutoCompleteTextView)findViewById(R.id.actvContacts);
          Cursor emailCursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
            startManagingCursor(emailCursor);
            autoContacts.setAdapter(new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, emailCursor, new String[] {Email.DATA1}, new int[] {android.R.id.text1}));
            autoContacts.setThreshold(0);

but when I click in one of the name then it sets a text in that Autocomplete textview like this:

android.content.ContentResolver$CursorWrapperInner@44efc9c8

but here I want to set the specific phone number on that, how to fix this issue?

  • 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-06-01T14:45:43+00:00Added an answer on June 1, 2026 at 2:45 pm

    You need to use the setCursorToStringConverter

    Sets the converter used to convert the filtering Cursor into a String.
    http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html

    In your case you could do something like this:

    String[] from = new String[] {
            ContactsContract.Contacts.DISPLAY_NAME,
            ContactsContract.CommonDataKinds.Phone.NUMBER
    };
    autoContacts=(AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
    Cursor emailCursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
    startManagingCursor(emailCursor);
    SimpleCursorAdapter adapter =new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, emailCursor, from, new int[] {android.R.id.text1}); 
    adapter.setCursorToStringConverter(new CursorToStringConverter() {              
            @Override
            public CharSequence convertToString(Cursor cursor) {
                final int columnIndex = cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER);
                final String str = cursor.getString(columnIndex);
                return str;
            }
    });
    autoContacts.setAdapter(adapter);
    autoContacts.setThreshold(0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some really funky code. As you can see from the code below
I have a database that uses codes. Each code can be anywhere from two
I have this code. Dim contact1 As XElement = _ <contacts> <contact> <%= From
I have a service with windows authentication. Using the following code, I can get
i need to read organization name from phone contacts in 2.1 i can read
What is analog in datamapper for .present? method? I have code from rails app
I have code examples from some of my previous work that help me to
I have code straight from Google's dev guide: Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(market://details?id=com.example.android));
I have borrowed code from this link PHP regex templating - find all occurrences
A lot of time I have to code from home. Normally I just remote

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.