8

how can I get the favourite contacts (and only the favorite / starred) contacts?

I would like to not loop through the entire contacts list checking each contact if it is starred... is there some query I can use to return only favourite/starred contacts?

thanks

ycomp
  • 8,316
  • 19
  • 57
  • 95
  • 1
    Refer to this: http://stackoverflow.com/questions/6351626/getting-favourites-contacts-in-android – C.d. Feb 11 '12 at 21:08

1 Answers1

10

You can do something like this:

Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, "starred=?",
            new String[] {"1"}, null);

where the starred=? will be your filter and "1" would suggest to pick up only favorites.

Uniruddh
  • 4,427
  • 3
  • 52
  • 86
V31
  • 7,626
  • 3
  • 26
  • 44
  • 3
    Instead of the hardcoded string `"starred"`, you should consider using [`ContactsContract.Contacts.STARRED`](https://developer.android.com/reference/android/provider/ContactsContract.ContactOptionsColumns.html#STARRED). – dst Dec 09 '16 at 17:07