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.
views:
127answers:
2Yes, I did a search a read all these before I posted... sigh.
Eno
2010-08-11 19:45:10
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
2010-08-11 20:17:28
I guess not knowing how the schema looks like doesn't help in understanding the code.
Eno
2010-08-12 15:42:49
First link on Google : "contacts android" : http://developer.android.com/reference/android/provider/Contacts.html
fedj
2010-08-12 18:12:38
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
2010-08-12 18:19:38
This is related to ContentProvider, there are lot of tutorials on them
fedj
2010-08-12 18:47:36
I implemented it myself eventually without much help from SO...
Eno
2010-09-23 20:55:53
There already is a ContentProvider for Contacts but for ContentProviders, the parameter after the projection is the selection (WHERE) clause
fedj
2010-09-24 13:20:07
A:
In onCreate():
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");
Created a SimpleCursorAdapter to connect data to the cursor.
Implemented setFilterQueryProvider() in my adapter to return a managed query when constraint is passed in when filtering.
The final step is to call setAdapter() on the TextView passing in your adapter.
Eno
2010-09-23 21:04:38