http://blog.csdn.net/qiaoning13256/article/details/6889315
1
2 /**
3 * 获得收藏夹的联系人
4 */
5 private void getKeepedContacts(){
6 Cursor cur = getContentResolver().query(
7 ContactsContract.Contacts.CONTENT_URI, null, ContactsContract.Contacts.STARRED + " = 1 " , null, null);
8 startManagingCursor(cur);
9 int num = cur.getCount();
10 System.out.println(num + "");
11 int count = 0;
12 while (cur.moveToNext()) {
13 count ++;
14
15 long id = cur.getLong(cur.getColumnIndex("_id"));
16 Cursor pcur = getContentResolver().query(
17 ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
18 null,
19 ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "="
20 + Long.toString(id), null, null);
21
22 // 处理多个号码的情况
23 String phoneNumbers = "";
24 while (pcur.moveToNext()) {
25 String strPhoneNumber = pcur
26 .getString(pcur
27 .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
28 phoneNumbers += strPhoneNumber + ":";
29 }
30 phoneNumbers += "\n";
31 pcur.close();
32 String name = cur.getString(cur.getColumnIndex("display_name"));
33 contactNameList.add(name);
34 contactNumList.add(phoneNumbers);
35 }
36 cur.close();
37 }