getting all contacts (including from other syncAdapters) in android content handler.

Posted by eyal on Stack Overflow See other posts from Stack Overflow or by eyal
Published on 2010-04-15T09:13:27Z Indexed on 2010/04/15 9:33 UTC
Read the original article Hit count: 434

Hi i have this Query:

 private Cursor getContacts(CharSequence constraint) {
  boolean hasConstrains = constraint != null && constraint.length() != 0;
  Uri uri = ContactsContract.Contacts.CONTENT_URI;
        String[] projection =  new String[]{ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME };
        String selection = hasConstrains ? projection[1] + " LIKE '"+constraint+"%'" : null;
        String[] selectionArgs = null;
        String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " ASC";
        return managedQuery(uri, projection, selection, selectionArgs, sortOrder);
 }

The first time issue it i give null as parameter to the function to the selection parameter is empty, meaning i don't filter any rows. The problem is i get only contacts i created myself using no syncAdapter. I used facebook app to synch my facebook contacts, but this query doesn't return them. I extracted the contacts2.db from the emulator and the view_contacts view shows me all the contacts, so the DB is updated.

What should i do to get all the contacts regardless of how they were created (with which synch adapter)

© Stack Overflow or respective owner

Related posts about android

Related posts about contacts