Android content provider not updating database

[亡魂溺海] 提交于 2019-12-11 20:19:13

问题


Forive me for any ignorance, but I really need help on this one and have tried Vogella and many tutorials to no avail !

My content provider query:

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
                   String sortOrder) {
    final SQLiteDatabase db = mOpenHelper.getReadableDatabase();

    final int match = sUriMatcher.match(uri);
    switch (match) {
        default: {
            // Most cases are handled with simple SelectionBuilder
            final SelectionBuilder builder = buildExpandedSelection(uri, match);
            builder.where(selection, selectionArgs).query(db, projection, sortOrder);
            builder.where(selection, selectionArgs).query(db, projection, sortOrder).setNotificationUri(getContext().getContentResolver(), uri);
            return builder.where(selection, selectionArgs).query(db, projection, sortOrder);
       }
   }
}

Update Section of Provider:

@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    LOGV(TAG, "update(uri=" + uri + ", values=" + values.toString() + ")");
    final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    final SelectionBuilder builder = buildSimpleSelection(uri);
    int retVal = builder.where(selection, selectionArgs).update(db, values);
    getContext().getContentResolver().notifyChange(uri, null);
    return retVal;
}

Fragment Stuff: Which is being executed in list view on click method

ContentValues values = new ContentValues();
values.put(NewaysContract.News.READ,1);
getActivity().getContentResolver()
             .update(CONTENT_URI,values,CONTENT+"=?",new String[] { contv });

来源:https://stackoverflow.com/questions/20578553/android-content-provider-not-updating-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!