I would manipulate the contact groups in Android 2.O. My code is following:
To get a list of group (with id and title):
final String[] GROUP_PROJECTION = new String[] { ContactsContract.Groups._ID, ContactsContract.Groups.TITLE };
Cursor cursor = ctx.managedQuery(ContactsContract.Groups.CONTENT_URI, GROUP_PROJECTION, null, null, ContactsContract.Groups.TITLE + " ASC");
Later, on an ListView, I select a group (onClick event) and read all contacts belong to this selected group by following code:
String where = ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID
+ "="
+ groupid
+ " AND "
+ ContactsContract.CommonDataKinds.GroupMembership.MIMETYPE
+ "='"
+ ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE
+ "'";
Problem: ContactsContract.Groups._ID in the first query does not match with the ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID in the second query.
Any solution/suggestion?
Thanks