views:

350

answers:

1

I would like to get a list of Contacts Groups already defined in the system, how can I do that?

+1  A: 

You can query the Contacts.Group table for the available groups.

You can use the Contacts.GroupMembership table to query what group a particular contact is a member of. PERSON_ID is the ID of the contact, GROUP_ID matches the ID of the group.

Note that both these APIs have been deprecated in favour of ContactsContract.Groups and ContactsContract.CommonDataKinds.GroupMembership from 2.0 onwards.

Jack Patmos
I don't see any method on the first link, to get the Groups, only some constants. Also can I create programmatically new groups? Do you know any tutorial or example for the first class(1.6)?
Pentium10
You need to use the ContentResolver.query() method to query the table. See: http://developer.android.com/intl/de/guide/topics/providers/content-providers.html This has info on programatically inserting new entries into a table too.
Jack Patmos
Do you happen to know the URI for the SDK 2.0+ to insert to?
Pentium10