views:

75

answers:

1

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

+2  A: 

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.

Jack Patmos
you're right. my solution was to build my project with 2.0 and use ContactsContract or the deprecated API depending on what OS it runs on. worked nicely.