嗨,实际上我这样做是为了获取所有有号码的联系人:
String[] projecao = new String[] { ContactsContract.Contacts._ID,
ContactsContract.Contacts.LOOKUP_KEY,
ContactsContract.Contacts.DISPLAY_NAME };
String selecao = ContactsContract.Contacts.HAS_PHONE_NUMBER + " = ? ";
Cursor contatos = contexto.getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, projecao, selecao,
new String[] { "1" }, null);
并获取每个联系人的所有号码:
while (contatos.moveToNext()){
Cursor numbers = contexto
.getContentResolver()
.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER },
ContactsContract.CommonDataKinds.Phone.CONTACT_ID
+ " = ?",
new String[] { contatos.getString(contatos
.getColumnIndex(ContactsContract.Contacts._ID)) },
null);
numbers.moveToFirst();
StringBuilder sb = new StringBuilder();
do {
sb.append(numbers.getString(numbers
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))
+ ", ");
} while (numbers.moveToNext());
}
但我不能选择来自 facebook 的号码。
我收到该错误:索引 0 请求。此错误是因为光标编号与任何编号都不匹配。