1

I am working on the displaying the contacts group wise in android application. So I got all the group contacts from the particular group but now I want to get the contacts those are not in any of the group (NOT ASSIGNED).

So what can be the value of GROUP_ROW_ID in the contacts's in case of no group ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID ?

If there any solution you know please let me know.

Any suggestion will be appreciated.

Rushabh Patel
  • 3,052
  • 4
  • 26
  • 58

2 Answers2

1

Please use,

 ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID = null;

This will get non-group contacts.

Thirumalvalavan
  • 2,660
  • 1
  • 30
  • 32
  • Has someone tested this? Do RawContacts without a group have a data row with Mimetype ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE? When this work it must be `[...] ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID + " IS NULL";` – Roel Jul 31 '15 at 12:43
-1

you can retrieve all contacts as a cursor.

Cursor cursor = getContentResolver().query(   ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null,null, null);

now we have cusror with contacts and get diffrent value from cusror.

while (cursor.moveToNext()) {
String name =cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));

String phoneNumber = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
 }

see this one http://samir-mangroliya.blogspot.in/p/android-read-contact-and-display-in.html

NagarjunaReddy
  • 8,621
  • 10
  • 63
  • 98