contactUri=ContactsContract.CommonDataKinds.Phone.CONTENT_URI;//contactUri for contactscontract
contactsCursor=getContentResolver().query(contactUri,null,null,null,Phone.DISPLAY_NAME +" ASC");
我想要来自联系人表格的不同数据(联系人姓名)。
答案 0 :(得分:0)
我认为你的意思是你有一些联系人的重复记录。因此,您必须为查询添加条件。
试试这个:
String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '"
+ ("1") + "'";
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME
+ " COLLATE LOCALIZED ASC";
cur = context.getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, projection, selection
+ " AND " + ContactsContract.Contacts.HAS_PHONE_NUMBER
+ "=1", null, sortOrder);// this query only return contacts which had phone number and not duplicated