I'm trying to get an autocompleteTextView with a custom cursor adapter
to allow a user to search his contacts and begin returning suggestions
from the first letter.  My problem i that the way i've implemented it
now, which is the only way I have found to return name and phone
numbers from the current API only returns one contact though....so if
i search "r" it returns only one contact beginning with r until i
actually spell out a specific name

Code:

 Cursor idCursor =mContent.query(uri, null, null, null, null);
                String id = null;

                while(idCursor.moveToNext())
                {
                        int idIdx =
idCursor.getColumnIndexOrThrow(ContactsContract.Contacts._ID);
                        id = idCursor.getString(idIdx);
                        Log.i(TAG, "idCursor count = " +idCursor.getCount());
                        Log.i(TAG, "ID"+ id);

                }
                idCursor.close();

             if(id != null)
                {

                        String where = ContactsContract.Data.CONTACT_ID + " = " 
+ id
+ " AND " +    ContactsContract.Data.MIMETYPE + " = '" +
                                                        
ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE
+ "'";

                        Cursor dataCursor =
mContent.query(ContactsContract.Data.CONTENT_URI, null, where, null,
null);
                        int nameIdx =
dataCursor.getColumnIndexOrThrow(ContactsContract.Data.DISPLAY_NAME);
                Log.i(TAG, "NameIdx " + nameIdx);
                        int phoneIdx =
dataCursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER) 
;
                        Log.i(TAG, "PhoneIdx " +phoneIdx);
                        int typeIdx =
dataCursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.TYPE);
                        Log.i(TAG, "typeIDx = " +typeIdx);
                        String[] result = new String[dataCursor.getCount()];
                        Log.i(TAG, "DataCursor = " +dataCursor.getCount());
                        if (dataCursor.moveToFirst())
                        do { // Extract the name.
                                String name = dataCursor.getString(nameIdx);
                                // Extract the phone number.
                                String number = dataCursor.getString(phoneIdx);
                                Log.i(TAG, "Number = " +number);
                                result[dataCursor.getPosition()] = name + " (" 
+ number +
")"; } while(dataCursor.moveToNext());


                        return dataCursor;

                }


Clearly the reason I can only get one name is obviously because I pass
the id from my first query.....So basically I am looking for the same
the effect as I have now that can match its query to multiple contact
ids

Any help?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to