views:

127

answers:

2

Ive read through the docs and searched on here, but Im not quite understanding how all the pieces fit together. Was wondering if anyone has a clear explanation of how to grab a single column of data from Contacts and have it populate an autocomplete box.

A: 

Check this link, duplicate post

fedj
Yes, I did a search a read all these before I posted... sigh.
Eno
This is well answered, if you need the code to be done by another person, that's not the right place. You should carefully read to the link, all you need is in.
fedj
I guess not knowing how the schema looks like doesn't help in understanding the code.
Eno
First link on Google : "contacts android" : http://developer.android.com/reference/android/provider/Contacts.html
fedj
Maybe specific questions would help: How to specify a query like "SELECT DATA from contact_methods where KIND=1" - what goes in the projection string, what is the constant to specify KIND and DATA? Can the selection string be "KIND=?" with selectionargs as "1" ?
Eno
This is related to ContentProvider, there are lot of tutorials on them
fedj
I implemented it myself eventually without much help from SO...
Eno
There already is a ContentProvider for Contacts but for ContentProviders, the parameter after the projection is the selection (WHERE) clause
fedj
A: 

In onCreate():

  1. Created a SimpleCursor to create a managed query into the contacts database:

    Cursor emailAddressCursor = managedQuery(Contacts.ContactMethods.CONTENT_EMAIL_URI, PROJECTION, null, null, Contacts.ContactMethods.DATA + " ASC");

  2. Created a SimpleCursorAdapter to connect data to the cursor.

  3. Implemented setFilterQueryProvider() in my adapter to return a managed query when constraint is passed in when filtering.

  4. The final step is to call setAdapter() on the TextView passing in your adapter.

Eno