Reputation: 626
Hi actually I'm doing this to get all contacts that has number:
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);
And to get all number of each contact:
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());
}
But I can't pick number that come from facebook.
I receive that error: index 0 request. This error is because the cursor numbers did not match any number.
Upvotes: 1
Views: 273
Reputation: 27596
Are you specifically trying to get phone numbers from Facebook contacts?
The FaceBook content provider is restricted. It will not let you retrieve phone numbers.
Please see this question or here or here.
Upvotes: 1