我已將聯繫人添加到我的地址簿中,該地址簿具有如下的多個號碼。 得到與一個聯繫人相關的所有手機號碼android
我想使用ContactsContract
內容uri獲取所有3個「用戶」號碼。 通過使用下面的代碼,我只有一個聯繫人。
Cursor cursorAddressBook = mContentResolver.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
if (cursorAddressBook != null) {
while (cursorAddressBook.moveToNext()) {
String dataName = cursorAddressBook.getString(cursorAddressBook.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String dataNumber = cursorAddressBook.getString(cursorAddressBook.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
int dataType = cursorAddressBook.getInt(cursorAddressBook.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DATA2));
String contactId = cursorAddressBook.getString(cursorAddressBook.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID));
Log.e("last updat Name last", dataName);
Log.e("last updated No last", dataNumber);
Log.e("last updated Type last", dataType);
}
cursorAddressBook.close();
}