I am trying to make a list of contacts that have email, phone or both.
For this purpose I am using ContentResolver
with URI set to ContactsContract.Data.CONTENT_URI
and I select by these conditions:
String SELECTION = ContactsContract.Data.DISPLAY_NAME_PRIMARY + "<>'' AND " + ContactsContract.Data.IN_VISIBLE_GROUP + "=1" + " AND (" + ContactsContract.Data.MIMETYPE + "=? OR " + ContactsContract.Data.MIMETYPE + "=?)";
String[] SELECTION_ARGS = new String[]{ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE,
ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE};
I am interested only in Name of such contact. But because Data table holds each information for given contact at separate row, the resulted cursor has duplicate entries in it.
Is there any way how to DISTINCT those entries? I am using CursorLoaderManager
with CursorAdapter
(maybe only way is to filter them out when loader finishes?).