14

What I want is to hide contacts from the contact list. So to achieve this I tried a lot and searched a lot. Finally I've come to know that we can generate an invisible group and we can assign contacts to that group so that contacts will be invisible.

I tried that, but had no success. Even when I set the GROUP_VISIBLE field of ContactsContact.Groups, I am not able to make my group invisible.

This is what I have tried to create a invisible group:

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

    ops.add(ContentProviderOperation
            .newInsert(ContactsContract.Groups.CONTENT_URI)
            .withValue(ContactsContract.Groups.GROUP_VISIBLE, 0)
            .withValue(ContactsContract.Groups.TITLE, "InViGroup").build());
    try {

        getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);

    } catch (Exception e) {
        Log.e("Error", e.toString());
    }

I am able to add contacts to this group but the contacts are visible in the phone book or the contact list.

My main goal is to hide the contact from contact list. Any ideas? How can I make my selected contacts invisible?

ekad
  • 14,436
  • 26
  • 44
  • 46
The Zero
  • 1,373
  • 9
  • 23
  • I would like to know this as well. I suspect one of the main problems is that GROUP_VISIBLE is a read_only field. have you found any alternative ways to doing this? – Maurycy Dec 13 '11 at 20:47
  • Why would you want to do this? Why not use a totally separate database for stuff you don't want to appear in Contacts lists? – Reuben Scratton Dec 13 '11 at 21:01
  • to take advantage of the contacts api features such as aggregation. Also allows for a lot less code. – Maurycy Dec 13 '11 at 21:17

2 Answers2

6

Maurycy, I played a lot with this to make it invisible. Even i am able to create a group with GROUP_VISIBLE to set true and false both. But whatever i set whether true or false the contacts i added are still visible to contacts app so finally i have created my own database of contacts maintaining in my own app.

It's more difficult than just to make invisible group and contacts in that as you have to maintain each and every fields and table related to contacts app's database. So if you have found ay way to make it invisible please let me know.

Still if you want security like no one can access or make it visible through code too than i think you should go with creating your own database method which i have selected as my last option.

The Zero
  • 1,373
  • 9
  • 23
0

I found a question here on SO where the person asking it has a code to add contacts that seems to make them invisible: Contact API storing contact as an invisible contact: How to make it visible?

Community
  • 1
  • 1
hlt
  • 6,219
  • 3
  • 23
  • 43