[英]android: ContentResolver works on 4.0 but not on 2.3
In the contacts provider I'm building I want to create contacts group and then add the contacts to that group. 在我正在建立的联系人提供程序中,我想创建联系人组,然后将联系人添加到该组。 This is my code for creating new group if one does not exist:
这是我创建不存在新组的代码:
if (groupId == 0) {
// Sample group doesn't exist yet, so create it
final ContentValues contentValues = new ContentValues();
contentValues.put(Groups.ACCOUNT_NAME, account.name);
contentValues.put(Groups.ACCOUNT_TYPE, account.type);
contentValues.put(Groups.TITLE, Constants.GROUP_NAME);
contentValues.put(Groups.GROUP_IS_READ_ONLY, true);
final Uri newGroupUri = resolver.insert(Groups.CONTENT_URI, contentValues);
Log.d(TAG, newGroupUri.toString());
groupId = ContentUris.parseId(newGroupUri);
}
When I run this on android 4.0 or 4.1 it works, but when I run this on 2.3 newGroupUri
is null. 当我在android 4.0或4.1上运行时,它可以工作,但是当我在2.3上运行时,
newGroupUri
为null。 What is the problem with 2.3. 2.3有什么问题。 I tried it both on emulator and phone
我在模拟器和电话上都尝试过
contentValues.put(Groups.GROUP_IS_READ_ONLY, true); contentValues.put(Groups.GROUP_IS_READ_ONLY,true); is only available since api 11
自api 11起可用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.