I am referring to the https://developer.android.com/reference/android/provider/ContactsContract.Contacts.Entity.html#CONTENT_DIRECTORY. And I want to use the ContactsContract.Contacts.Entity URI for better results. APi level is 11 and my device OS is 4.0. I am using below code. And below is the exception I am getting in logs.
Please advice in which way I can use the ContactsContract.Contacts.Entity API.
Caused by: java.lang.IllegalArgumentException: URI: content://com.android.contacts/contacts/entities
Cursor phones=null;
ContentResolver cr = getContentResolver();
Uri phoneuri = Contacts.CONTENT_URI;
Uri phone_uri = phoneuri.withAppendedPath(phoneuri, ContactsContract.Contacts.Entity.CONTENT_DIRECTORY);
phones = cr.query(phone_uri, null, null, null, null);
for(int i=0;i<phones.getCount();i++)
{
Log.e("int","f_name="+phones.getColumnName(i));
}
phones.close();
Use this code to get all contacts from android:
Hope this will help you.