重复的联系人Android

时间:2012-02-20 05:23:47

标签: android duplicates contacts

我正在使用这段代码从Android手机获取联系人:

Contact contactDataObject = null;
        String[] values = new String[] {ContactsContract.Contacts._ID,ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.LOOKUP_KEY, ContactsContract.Contacts.HAS_PHONE_NUMBER}; 
        Cursor c = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, values, null, null, Phone.DISPLAY_NAME + " ASC");
         while(c.moveToNext()){
          String contactId = c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));
          String name = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
          String lookupKey = c.getString(c.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
          String hasPhone =c.getString(
                  c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
          if(Integer.parseInt(hasPhone) == 1){

               contactDataObject = new Contact();
               contactDataObject.setmName(name);
               contactDataObject.setmId(contactId);
               contactDataObject.setmLookupKey(lookupKey);
               arr.add(contactDataObject);
          }

问题在于重复的联系人。联系人显示在SIM卡和手机上。我怎样才能通过电话获得联系人?

提前谢谢!

0 个答案:

没有答案