Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Invisible Contacts Group in Android

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?

like image 386
The Zero Avatar asked Nov 25 '11 07:11

The Zero


1 Answers

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.

like image 198
The Zero Avatar answered Oct 10 '22 22:10

The Zero