任何无知都可以让我失望,但我真的需要帮助,并尝试过Vogella和许多教程无济于事!
我的内容提供商查询:
@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);
}
}
}
更新提供商部分:
@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;
}
片段资料:点击方法
在列表视图中执行
ContentValues values = new ContentValues();
values.put(NewaysContract.News.READ,1);
getActivity().getContentResolver()
.update(CONTENT_URI,values,CONTENT+"=?",new String[] { contv });