/** * Handle updating data. */ public override int Update(Uri uri, Android_Content.ContentValues values, string where, string[] whereArgs) { SQLiteDatabase db = mOpenHelper.GetWritableDatabase(); int count; string constWhere; switch (mUriMatcher.Match(uri)) { case MAIN: // If URI is main table, update uses incoming where clause and args. count = db.Update(MainTable.TABLE_NAME, values, where, whereArgs); break; case MAIN_ID: // If URI is for a particular row ID, update is based on incoming // data but modified to restrict to the given ID. constWhere = DatabaseUtilsCompat.ConcatenateWhere( IBaseColumnsConstants._ID + " = " + Android_Content.ContentUris.ParseId(uri), where); count = db.Update(MainTable.TABLE_NAME, values, constWhere, whereArgs); break; default: throw new System.ArgumentException("Unknown URI " + uri); } GetContext().GetContentResolver().NotifyChange(uri, null); return count; }
/** * Handle deleting data. */ public override int Delete(Uri uri, string where, string[] whereArgs) { SQLiteDatabase db = mOpenHelper.GetWritableDatabase(); string constWhere; int count; switch (mUriMatcher.Match(uri)) { case MAIN: // If URI is main table, delete uses incoming where clause and args. count = db.Delete(MainTable.TABLE_NAME, where, whereArgs); break; // If the incoming URI matches a single note ID, does the delete based on the // incoming data, but modifies the where clause to restrict it to the // particular note ID. case MAIN_ID: // If URI is for a particular row ID, delete is based on incoming // data but modified to restrict to the given ID. constWhere = DatabaseUtilsCompat.ConcatenateWhere( IBaseColumnsConstants._ID + " = " + Android_Content.ContentUris.ParseId(uri), where); count = db.Delete(MainTable.TABLE_NAME, constWhere, whereArgs); break; default: throw new System.ArgumentException("Unknown URI " + uri); } Context.GetContentResolver().NotifyChange(uri, null); return(count); }