views:

422

answers:

1

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

A: 

I worked a lot with Contact Groups, and as I remember those code fragments up there are from my other posts. The code does work for me, and should work for you too.

I don't see why the two data should not match. Please double check again.

Pentium10