batman
batman

Reputation: 2478

Android: Show all contacts sorted by favorites

I know how to fetch all contacts as well as how to fetch the favorited contacts. Is there a way to combine the two and sort by favorites?

getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, "starred=?", new String[] {"1"}, <sort by favorites?>);

Upvotes: 0

Views: 178

Answers (1)

Try to use this query to get all contacts order by favorites and then by display name.

getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null, 
null, 
null,
ContactsContract.Contacts.STARRED + " DESC, " + ContactsContract.Contacts.DISPLAY_NAME_PRIMARY + " ASC");

Upvotes: 1

Related Questions