1

I known how retrieve the group ids at that belongs a contact

Cursor cursor = context.getContentResolver().query(
    ContactsContract.Data.CONTENT_URI, new String[] {
        ContactsContract.Data.DATA1
    }, 
    String.format("%s=? AND %s=?", ContactsContract.Data.CONTACT_ID, ContactsContract.Data.MIMETYPE), 
    new String[] { 
        Long.toString(contact_id),
        ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE 
    }, null);

and also how obtain the group name if I known the id.

Cursor cursor = getContentResolver().query(
    ContactsContract.Groups.CONTENT_URI, new String[] {
        ContactsContract.Groups.TITLE
    }, 
    String.format("%s=?", ContactsContract.Groups._ID), 
    new String[] { Long.toString(id) }, 
    null);

But is possible to obtains the group names at that belongs a contact (by id) in a single query?

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
The Matrix
  • 1,268
  • 2
  • 14
  • 23

0 Answers0