突然被这个问题难到,
ContentValues values = new ContentValues();
values.put(Cards.WinCount,1);
db.update(Card_LIST_TABLE_NAME, values, where, whereArgs);
暂不使用rawQuery与先SELECT然后把原值读出来加1后再UPDATE的办法,用ContentValues 能实现吗?
求高手指点.

解决方案 »

  1.   

    你这里的db是指SQLiteDatabase对象吧?它里边的update方法就是用来更新数据的:  /**
         * Convenience method for updating rows in the database.
         *
         * @param table the table to update in
         * @param values a map from column names to new column values. null is a
         *            valid value that will be translated to NULL.
         * @param whereClause the optional WHERE clause to apply when updating.
         *            Passing null will update all rows.
         * @return the number of rows affected
         */
        public int update(String table, ContentValues values, String whereClause, String[] whereArgs) {
            return updateWithOnConflict(table, values, whereClause, whereArgs, null);
        }