Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何查询数据表中的数据?_Android_Contacts - Fatal编程技术网

Android 如何查询数据表中的数据?

Android 如何查询数据表中的数据?,android,contacts,Android,Contacts,我使用以下代码在数据表中插入了两行: ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI).withValue( RawContacts.ACCOUNT_TYPE, null).withValue(RawContacts.ACCOUNT_NAME, null).build()); ops.add(ContentProviderOper

我使用以下代码在数据表中插入了两行:

ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI).withValue(
                RawContacts.ACCOUNT_TYPE, null).withValue(RawContacts.ACCOUNT_NAME,
                null).build());

        ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI).withValueBackReference(
                Data.RAW_CONTACT_ID, rawContactInsertIndex).withValue(Data.MIMETYPE,
                StructuredName.CONTENT_ITEM_TYPE).withValue(StructuredName.DISPLAY_NAME,
                "a").build());
        ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI).withValueBackReference(
                Data.RAW_CONTACT_ID, rawContactInsertIndex).withValue(Data.MIMETYPE,
                        GroupMembership.CONTENT_ITEM_TYPE).withValue(CommonDataKinds.GroupMembership.GROUP_ROW_ID,
                        "groupa").build());
所以我在数据表中增加了两行。但当我想获取联系人的groupId(显示名称为a)时,我不知道怎么做。

谢谢

我觉得比内容提供商更适合使用SQLite3。

我自己找到了答案。RawContactsEntity可以很好地解决这个问题。

但我正在从事android源代码项目之外的一个项目,所以这似乎是使用内容提供商获取联系人数据库信息的唯一方法。我很痛苦。