Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get only the favourite/starred contacts using ContactsContract

Tags:

android

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

like image 420
ycomp Avatar asked Feb 11 '12 19:02

ycomp


People also ask

How do you make starred contacts?

Marking a contact as a favorite is easy, just tap on a contact's name, then select the "star" icon up at the top of the contact card. You'll then be able to see a combination of these favorite contacts and your frequently contacted people from the "Favorites" tab of the People app.

How do I select favorite contacts on Android?

On your Android phone or tablet, open the Contacts app . Tap the contact you want to add to your favorites. At the top, tap Favorite .


1 Answers

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.

like image 87
V31 Avatar answered Oct 19 '22 22:10

V31