此方法此刻只会用所选值覆盖当前值。我试图添加到信用列中已有的当前数字。我需要添加/更改此代码才能实现此目的?我一直在查看很多问题,但无法弄清楚。
public void upDateUser(int money)
{
String selectQuery = "SELECT " + KEY_CREDITS + " from " +
DATABASE_TABLE + " where " + KEY_ROWID + " = " + 0;
Cursor c = ourDatabase.rawQuery(selectQuery, null);
int oldMoney = 0;
if (c.moveToFirst())
{
oldMoney = oldMoney + Integer.parseInt(c.getString(4));
}
ContentValues cvUpdate = new ContentValues();
cvUpdate.put(KEY_CREDITS, (oldMoney + money));
ourDatabase.update(DATABASE_TABLE, cvUpdate, null, null);
}