Android getContentResolver().update 想在原来值加1能行吗?

遊戲王千金 2012-01-31 05:44:19
突然被这个问题难到,
ContentValues values = new ContentValues();
values.put(Cards.WinCount,1);
db.update(Card_LIST_TABLE_NAME, values, where, whereArgs);
暂不使用rawQuery与先SELECT然后把原值读出来加1后再UPDATE的办法,用ContentValues 能实现吗?
求高手指点.
...全文
455 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
BadPattern 2012-02-01
  • 打赏
  • 举报
回复
你这里的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);
}




遊戲王千金 2012-02-01
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dr8737010 的回复:]
可以实现,你可以写代码试试嘛
[/Quote]
能否详细点。
BadPattern 2012-01-31
  • 打赏
  • 举报
回复
可以实现,你可以写代码试试嘛

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧