android:ContentResolver可以在4.0上工作,但不能在2.3上工作
在我正在构建的联系人提供程序中,我要创建联系人组,然后将联系人添加到该组。这是我在不存在新组时创建新组的代码:android:ContentResolver可以在4.0上工作,但不能在2.3上工作,android,android-contentprovider,android-contentresolver,android-syncadapter,Android,Android Contentprovider,Android Contentresolver,Android Syncadapter,在我正在构建的联系人提供程序中,我要创建联系人组,然后将联系人添加到该组。这是我在不存在新组时创建新组的代码: if (groupId == 0) { // Sample group doesn't exist yet, so create it final ContentValues contentValues = new ContentValues(); contentValues.put(Groups.ACCOUNT_NAME, accoun
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);
}
当我在安卓4.0或4.1上运行时,它可以工作,但当我在2.3newGroupUri
上运行时,它是空的。2.3有什么问题。我在emulator和手机上都试过它contentValues.put(Groups.GROUP\u是只读的,true);仅在api 11之后可用