Is it possible, with ContactsUtils or otherwise, to create a contact group. I can add a group membership to a contact but can't figure out how to add a new group or even test if an existing group exists.
On further thought I have included the following code in ContactsUtils
B4X:
Public Sub SetGroup(Id As Long, GroupID As Int)
Dim values As ContentValues
values.Initialize
values.PutInteger("data1", GroupID)
SetData("vnd.android.cursor.item/group_membership", values, Id, False)
End Sub
and use it as below
B4X:
cu.SetGroup(myID, groupID)
where myID is the ID returned by cu.InsertContact and GroupID is the group_membership (as logged using PrintAggregatedDataFields) of a contact which belongs to the group I want to set for the new contact.
When I include this after I create the contact it doesn't seem to add the group membership and my contact sync stop working correctly. There is obviously something wrong but what? Should I be using the raw_contact_id rather than the contact_id?
The above is my attempt to add group membership which (as stated in my first post) I thought was working but now seems to have stopped. So I can create the groups manually but need to get this adding group membership working before I attempt to create the groups in code.
After some further experimenting I discovered that my code to set the group membership worked ok but only when I ran it as a separate activity after creating the contacts and syncing with my Google account. Maybe a timing issue and the same applied to setting notes.