Android内容提供商更新无效

时间:2015-04-16 23:37:14

标签: android sqlite sql-update android-contentprovider

我有一个代码可以更新名为status的列,但是没有进行更新。

以下是我如何致电提供商:



ContentValues values = new ContentValues(1);
		values.put(ChatDataProvider.COL_STATUS, 0);
		getContentResolver().update(Uri.withAppendedPath(ChatDataProvider.CONTENT_URI_MESSAGES, "lastcliq/" + userIdOther.toString()), values, null, null);	




这是我的更新覆盖:



	@Override
	public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
		SQLiteDatabase db = dbHelper.getWritableDatabase();
		int count = 0;
		switch(uriMatcher.match(uri)) {
		case MESSAGES_LAST_MSG_BY_ID:
			count = db.update(TABLE_MESSAGES, values, COL_USER_ID_TO + " = ?", new String[]{uri.getLastPathSegment()});	
			break;	
		default:
			throw new IllegalArgumentException("Unsupported URI: " + uri);			
		}
		getContext().getContentResolver().notifyChange(uri, null);
		return count;
	}




奇怪的是" db.update"返回2的计数是正确的,但COL_STATUS的值不设置为0,因为当我再次查询时,相同的行仍然具有status = 1.

我的Content Provider中的所有其他方法都按预期执行。

0 个答案:

没有答案
相关问题