javaandroidandroid-contactscontactscontract

Contacts group GROUP_VISIBLE and GROUP_IS_READ_ONLY ignored?


Can someone explain me why this parameters GROUP_IS_READ_ONLY (set to 0) and GROUP_VISIBLE (set to false) are ignored when my group is created?

I can still see group and contacts in it and also I can delete/modify my group and contacts in it.

EDIT

This is how I create a group:

ArrayList<ContentProviderOperation> ops = new ArrayList<>();

ops.add(ContentProviderOperation.newInsert(Groups.CONTENT_URI)
                    .withValue(Groups.TITLE, groupName)
                    .withValue(Groups.ACCOUNT_NAME, accountName)
                    .withValue(Groups.ACCOUNT_TYPE, AccountGeneral.ACCOUNT_TYPE)
                    .withValue(Groups.GROUP_VISIBLE, false)
                    .withValue(Groups.GROUP_IS_READ_ONLY, 1)
                    .build());

mContentResolver.applyBatch(ContactsContract.AUTHORITY, ops);

And this is what official developer android page said:

GROUP_VISIBLE - Flag indicating if the contacts belonging to this group should be visible in any user interface.

GROUP_IS_READ_ONLY - The "read-only" flag: "0" by default, "1" if the row cannot be modified or deleted except by a sync adapter. See ContactsContract.CALLER_IS_SYNCADAPTER.

Thanks!


Solution

  • So, to continue from the comments section, the answer is that your input values are ok, and persisted as requested.

    However, the Contacts app (or any other app that reads contacts) can just ignore the values at GROUP_VISIBLE and display all contacts on the phone. Usually apps provide some filter capabilities to the user, so the user can choose if she wants to see only contacts in visible groups, all contacts on the phone, or a specific group.

    If you query for contacts using the IN_VISIBLE_GROUP selection, then you should not get the contacts created under your group in the cursor response.