Question

My Android app has a ContactsList activity in which I simply display a list of contacts that are on the phone.

Only recently I noticed that my activity only displays contacts synced with my main Google account. I have two Google accounts on my test phone and ideally I want my activity to display the contacts for both accounts (or multiple accounts).

How do I query across multiple accounts?

This is how I setup my cursor currently

Cursor c = getContentResolver().query(Phones.CONTENT_URI, null,
            queryString, null, Phones.DISPLAY_NAME + " ASC");
    startManagingCursor(c);

On a side note, I know android.provider.contacts.phones is deprecated and I should be using ContactsContract but I need to build my app with SDK 1.5, which doesn't have ContactsContract

Was it helpful?

Solution

You can continue to use the deprecated Contacts APIs but they only work with the first Google account assigned to the phone- they will not work with multiple accounts, as noted in the documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top