I have a program which reads the contacts and then displays it into the ListView
. But the problem is that I have total 25k + contacts in my phone and 60% contacts are of google. So it takes too much time to read contacts. How do I read contacts having phone number ?
I'm using this code :
Cursor phones = as.getApplicationContext().getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, null);
while (phones.moveToNext())
{
String name=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
}
phones.close();
Where clause can be used to filter the contacts with the phone numbers. Use the below code to retrieve the contacts.
For reading the contacts you need the following permission.