I am trying to get all contacts in the favourites list of the Android contacts. Currently, I can get all the group ids including the favourite group ID. But it seems that there is no contacts that have the group ID as the favourite group ID.
I'm trying to get All groups id and contacts in each group. After printing two list, I found that the group id of favorite is not in the contact list
ArrayList<String> favGroupId=new ArrayList<String>();
final String[] GROUP_PROJECTION = new String[] {
ContactsContract.Groups._ID, ContactsContract.Groups.TITLE };
Cursor cursor = getContentResolver().query(
ContactsContract.Groups.CONTENT_URI, GROUP_PROJECTION, null,
null, ContactsContract.Groups.TITLE);
while (cursor.moveToNext()) {
String id = cursor.getString(cursor
.getColumnIndex(ContactsContract.Groups._ID));
Log.v("Test",id);
String gTitle = (cursor.getString(cursor
.getColumnIndex(ContactsContract.Groups.TITLE)));
Log.v("Test",gTitle);
if (gTitle.contains("Favorite_")) {
gTitle = "Favorites";
favGroupId.add(id);
}
}
cursor.close();
Open your Contacts application and touch the Groups tab at the top of the screen, then touch Favorites. Favorites lists the contacts you've added to the list, followed by a list of your most frequently called 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.
You can use the STARRED field in the ContactsContract.Contact class. If you change your query to:
Cursor cursor = this.managedQuery(
ContactsContract.Contacts.CONTENT_URI, projection, "starred=?",
new String[] {"1"}, null);
this should return a list of all contacts that appear in the Favorites tab in the default Contacts app on Android.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With