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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:08:42+00:00 2026-06-06T08:08:42+00:00

I am trying the following code to AutoComplete contact details as the user types

  • 0

I am trying the following code to AutoComplete contact details as the user types for my android app.

public class MakePayment extends Activity {
    private AutoCompleteTextView mAuto;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.makepayment);

        mAuto = (AutoCompleteTextView)findViewById(R.id.autoCompleteTextViewTest);
        ContentResolver content = getContentResolver();
        Cursor cursor = content.query(ContactsContract.Contacts.CONTENT_URI,
                PEOPLE_PROJECTION, null, null, null);

        ContactListAdapter adapter = new ContactListAdapter(this, cursor);
        mAuto.setAdapter(adapter);
    }

     public static class ContactListAdapter extends CursorAdapter implements Filterable {
            public ContactListAdapter(Context context, Cursor c) {
                super(context, c);
                mContent = context.getContentResolver();
            }

            @Override
            public View newView(Context context, Cursor cursor, ViewGroup parent) {
                 final LayoutInflater inflater = LayoutInflater.from(context);
                    final TextView view = (TextView) inflater.inflate(
                            android.R.layout.simple_dropdown_item_1line, parent, false);
                    view.setText(cursor.getString(3));
                    return view;
            }        

            @Override
            public void bindView(View view, Context context, Cursor cursor) {
                ((TextView) view).setText(cursor.getString(3));

            }

            @Override
            public String convertToString(Cursor cursor) {
                return cursor.getString(3);
            }

            @Override
            public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
                if (getFilterQueryProvider() != null) {
                    return getFilterQueryProvider().runQuery(constraint);
                }

                StringBuilder buffer = null;
                String[] args = null;
                if (constraint != null) {
                    buffer = new StringBuilder();
                    buffer.append("UPPER(");
                    buffer.append(ContactsContract.Contacts.DISPLAY_NAME);
                    buffer.append(") GLOB ?");
                    args = new String[] { constraint.toString().toUpperCase() + "*" };
                }

                return mContent.query(ContactsContract.Contacts.CONTENT_URI, PEOPLE_PROJECTION,
                        buffer == null ? null : buffer.toString(), args,
                        null);
            }

            private ContentResolver mContent;           
        }

     private static final String[] PEOPLE_PROJECTION = new String[] {
            ContactsContract.CommonDataKinds.Phone.CONTACT_ID,
            ContactsContract.CommonDataKinds.Phone.NUMBER,
            ContactsContract.CommonDataKinds.Email.DATA,
            ContactsContract.Contacts.DISPLAY_NAME,
        };

}

But my app shuts down giving the following errors:

06-21 10:33:26.970: E/AndroidRuntime(31086): FATAL EXCEPTION: main
06-21 10:33:26.970: E/AndroidRuntime(31086): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.MyApp/com.MyApp.MakePayment}: java.lang.IllegalArgumentException: Invalid column contact_id
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1713)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.app.ActivityThread.startActivityNow(ActivityThread.java:1541)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:696)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.widget.TabHost.setCurrentTab(TabHost.java:328)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:134)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:518)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.view.View.performClick(View.java:2485)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.view.View$PerformClick.run(View.java:9089)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.os.Handler.handleCallback(Handler.java:587)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.os.Handler.dispatchMessage(Handler.java:92)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.os.Looper.loop(Looper.java:130)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.app.ActivityThread.main(ActivityThread.java:3906)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at java.lang.reflect.Method.invokeNative(Native Method)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at java.lang.reflect.Method.invoke(Method.java:507)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:840)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:598)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at dalvik.system.NativeStart.main(Native Method)
06-21 10:33:26.970: E/AndroidRuntime(31086): Caused by: java.lang.IllegalArgumentException: Invalid column contact_id
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:372)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.content.ContentProviderProxy.query(ContentProviderNative.java:408)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.content.ContentResolver.query(ContentResolver.java:266)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at com.MyApp.MakePayment.onCreate(MakePayment.java:28)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-21 10:33:26.970: E/AndroidRuntime(31086):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1677)

It says invalid column contacts_id. Am I doing anything wrong here?

  • 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-06T08:08:43+00:00Added an answer on June 6, 2026 at 8:08 am

    use

     Cursor cursor = content.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                    PEOPLE_PROJECTION, null, null, null);
    

    instead of

     Cursor cursor = content.query(ContactsContract.Contacts.CONTENT_URI,
                    PEOPLE_PROJECTION, null, null, null);
    

    and see docs for ContactsContract.Contacts CONTACT_ID,NUMBER,DATA and DISPLAY_NAME is not filed of ContactsContract.Contacts these all are in ContactsContract.CommonDataKinds

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

Sidebar

Related Questions

When I am trying to execute following code to email the contact form details,
I'm trying to implement autocomplete for a textbox using the following code, but it's
I have the following code : public class Main { private int i =
I am trying the following sample app for twitter oauth. http://www.androidsdkforum.com/android-sdk-development/3-oauth-twitter.html private void askOAuth()
I am trying Jquery Autocomplete element.In code I can see following import and references
I am using Android 2.2. I am trying following code to run: Uri uri=Uri.parse(http://bluediamondring-s.com/wp-content/uploads/2010/08/gold-ring.jpg);
I am a beginner with Java, and I am trying the following code: public
I'm trying the following code http://code.google.com/apis/ajax/playground/#change_the_playing_video It works well when runned from the playground
I'm trying the following code to execute a search and it's not working. On
I was trying out the following code which actually saves the pdf file to

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.