I want to get all contact name along with phone number size in it. Now I am using tow queries:
1.
crContacts = getContentResolver()
.query(ContactsContract.Contacts.CONTENT_URI, null,null, null, null)
and then 2.
while (crContacts.moveToNext()) {
id = crContacts.getString(crContacts.getColumnIndex(ContactsContract.Contacts._ID));
Cursor crPhones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID
+ " = ?", new String[]{id}, null);
}
Any way to get phone number size and Phone.DISPLAY_NAME_PRIMARY once without query twice?
Not sure what you mean by phone number size, but you can easily access all
Phone.CONTENT_URIfields along with implicit joins from theContacts.CONTENT_URItable, here's an example:You can read more about the implicit joins you get when querying any Data table here: https://developer.android.com/reference/android/provider/ContactsContract.Data#columns