I create a user interface where I need to show the phone's contact list as a list.
I use ContactsContract.Data and CursorLoader to load data, and then bind the cursor to a user adapter (extended from SimpleCursorAdapter ).
The problem is that I cannot figure out how to filter the SIM card contacts; on the test phone I have the same contacts on the phone, as well as on the SIM card, which leads to duplicate entries in the list. If I remove the SIM, the duplicates will disappear.
How can I disconnect this filter from the contacts of the SIM card? I am looking for a way to get data using 1 query.
This is how I upload my data at the moment:
Uri queryUri = ContactsContract.Data.CONTENT_URI; String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Data.MIMETYPE, ContactsContract.RawContacts.ACCOUNT_TYPE }; selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = 1 AND IS_PRIMARY = 1 AND MIMETYPE = '" + Phone.CONTENT_ITEM_TYPE + "'"; cursorLoader = new CursorLoader(getActivity(), queryUri, projection, selection, null, ContactsContract.Contacts.DISPLAY_NAME); cursor = cursorLoader.loadInBackground();
source share