I can not get the phone number to add to my list, does anyone know?
public void pegarContatos() {
Uri agenda = ContactsContract.Contacts.CONTENT_URI;
Cursor cursor = getContentResolver().query(agenda, null, null, null, null);
while (cursor.moveToNext()) {
int telefone = cursor.getInt(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
if(telefone == 1) {
int ID = cursor.getColumnIndex(ContactsContract.Contacts._ID);
String nome = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
Contato contato = new Contato(ID ,nome);
listaDeContatos.add(contato);
}
}
this.lista();
cursor.close();
}