简体   繁体   English

android:ContentResolver在4.0上有效,但在2.3上无效

[英]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.

相关问题 Android代码可在2.3上使用,但不能在4.0上使用 - Android Code Works On 2.3 But Not On 4.0 Android主要XML在2.3和4.0上的工作方式有所不同 - android main XML works diffrent on 2.3 and 4.0 在Android上捕获媒体按钮> = 4.0(适用于2.3) - Capture media button on Android >=4.0 (works on 2.3) Android 4.0中的类无响应-在2.3及以下版本中有效 - No response from class in Android 4.0 - works in 2.3 and below ActionBar - Android平板电脑2.3和4.0 - ActionBar - Android Tablet 2.3 and 4.0 Android应用程序只能在2.3上运行,而不能在4.0上运行 - Android app working on 2.3 but not on 4.0 Phonegap应用程序在运行Android 4.0时引发错误,但在Android 2.3及更低版本上可以正常运行 - Phonegap application throws error running Android 4.0, but works fine on Android 2.3 and below SHOUTCast Streaming Breaks in 4.0+,适用于2.3 - SHOUTCast Streaming Breaks in 4.0+, works in 2.3 Android我的应用程序可以在2.3上运行,但即使在4.0上也无法启动 - Android My application works on 2.3 fine but doesn't start even on 4.0 在Android 2.3和Android 4.0上联系photo uri - Contacts photo uri on Android 2.3 and Android 4.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM