Uri MUri =uri.parse ("content://com.android.contacts/contacts?android.provider.extra.address_book_index=true& Directory=0 ");//contactscontract.commondatakinds.phone.content_uri; URI of the contact person
string[] mprojection = new string[] {
contacts._id,//0
Contacts.display_name_primary,//1
Contacts.contact_presence,//2
Contacts.contact_status,//3
CONTACTS.PHOTO_ID,//4
Contacts.photo_thumbnail_uri,//5
Contacts.lookup_key,//6
Contacts.is_user_profile,//7
Contacts.phonetic_name,//8
Contacts.indicate_phone_sim,
Contacts.index_in_sim,
Contacts.is_sdn_contact,
Contacts.is_sdn_contact,
};
int mselecttype = 0;
if (mselecttype==0)
Mqueryhandler.startquery (Query_token, NULL, URI, projection, getcontactselection (), NULL, Getsortorder (projection)) ;//all
else if (mselecttype==1)//sim1
Mqueryhandler.startquery (0, NULL, MUri, mprojection, "EXISTS" (SELECT DISTINCT contact_id from View_raw_contacts WHERE _sdn_contact < 1 and contact_id = view_contacts._id, account_type= ' USIM account ' and account_name= ' USIM1 ' and Data_ ' Set is null)) ", NULL," Sort_key ");
else if (mselecttype==2)//sim2
Mqueryhandler.startquery (0, NULL, MUri, mprojection, "EXISTS" (SELECT DISTINCT contact_id from View_raw_contacts WHERE _sdn_contact < 1 and contact_id = view_contacts._id, account_type= ' USIM account ' and account_name= ' USIM2 ' and Data_ ' Set is null)) ", NULL," Sort_key ");
Else
Mqueryhandler.startquery (0, NULL, MUri, mprojection, "EXISTS" (SELECT DISTINCT contact_id from View_raw_contacts WHERE _sdn_contact < 1 and contact_id = view_contacts._id and (Account_type is null and account_name-is null and Data_set I S null OR account_type= ' local phone account ' and account_name= ' phone ' and data_set are null) ', NULL, ' Sort_key ';//phon E