Android 获取 联系人信息
Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
null, null, null);
List<String> numbers = null;
while (cursor.moveToNext()) {
numbers = new ArrayList<String>();
// 获取联系人
int nameFieldColumnIndex = cursor
.getColumnIndex(PhoneLookup.DISPLAY_NAME);
String name = cursor.getString(nameFieldColumnIndex);
// 获取 ID
int idFieldColumnIndex = cursor
.getColumnIndex(ContactsContract.Contacts._ID);
String contactId = cursor.getString(idFieldColumnIndex);
System.out.println("contactId --- > "+contactId);
// 获取电话号码
Cursor phones = cr
.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "="
+ contactId, null, null);
System.out.println("phones --- > "+phones.getCount());
while (phones.moveToNext()) {
int phoneFieldColumnIndex = phones
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
String phonenum = phones.getString(phoneFieldColumnIndex);
System.out.println("Numbers --- " + phonenum);
numbers.add(phonenum);
}