I am able to get total number of contacts but the problem is, its coming from the sqlite and the number of contacts in the phonebook is different from the number I am getting from the database. Here's my code for that:
Cursor cursor = managedQuery(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
// Or this cursor
Cursor cursor = managedQuery(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null,
null, null);
int count = cursor.getCount();
try {
tv1.setText(String.valueOf(count));
Log.i("Contacts: ", String.valueOf(count));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I am able to get the total number of contacts in the database but its different from the contacts displayed in the phonebook.
Any suggestions or help will be really appreciated.