I tried to get all group from android device with below code. Then I put all group name and id in arraylist.
Uri CONTENT_URI = ContactsContract.Groups.CONTENT_URI;
String GR_ID = ContactsContract.Groups._ID;
String GR_TITLE = ContactsContract.Groups.TITLE;
ContentResolver cr = getContentResolver();
Cursor groupCursor = cr.query(CONTENT_URI, null, null, null,
ContactsContract.Groups._ID + " ASC");
while (groupCursor.moveToNext()) {
String group_id = groupCursor.getString(groupCursor.getColumnIndex(GR_ID));
String group_name = groupCursor.getString(groupCursor.getColumnIndex(GR_TITLE));
Group grp = new Group(group_name);
grp.setId(group_id);
arrayPersonal.add(grp);
}
groupCursor.close();
This is result
Some group have different id but same name. I dont know why? Any help would be much appreciated! Thanks!