簡體   English   中英

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

[英]android: ContentResolver works on 4.0 but not on 2.3

在我正在建立的聯系人提供程序中,我想創建聯系人組,然后將聯系人添加到該組。 這是我創建不存在新組的代碼:

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);
    }

當我在android 4.0或4.1上運行時,它可以工作,但是當我在2.3上運行時, newGroupUri為null。 2.3有什么問題。 我在模擬器和電話上都嘗試過

contentValues.put(Groups.GROUP_IS_READ_ONLY,true); 自api 11起可用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM