我有以下代码:
//get group ID's
// note: a contact can belong to multiple groups
final String where = ContactsContract.Data.RAW_CONTACT_ID + "=" + contactID
+ " AND "
+ ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE + "'";
final String[] projectionGroups = new String[] { ContactsContract.Data.DATA1 };//DATA1 is GroupID
Cursor curGroup = getContentResolver().query(
ContactsContract.Data.CONTENT_URI,
projectionGroups,
where,
null,
null);
if (curGroup != null)
{
Log.i(TAG, "group count "+curGroup.getCount());
}
但是,它始终返回计数 0。
查询有问题吗?我在运行 Android 2.3.5 的手机上使用它