private void updateTran(Transaction trans) { db.beginTransaction(); try { ContentValues newValue = tranValues(trans); String[] args = {Integer.toString(trans.ID)}; db.update("trans", newValue, "_id=?", args); db.setTransactionSuccessful(); } finally { db.endTransaction(); } }
private void updateAccount(Account acct) { db.beginTransaction(); try { ContentValues newValue = acctValues(acct); String[] args = {Integer.toString(acct.ID)}; db.update("acct", newValue, "_id=?", args); db.setTransactionSuccessful(); } finally { db.endTransaction(); } }
/* * * 修改一条数据 */ public void update(String table, ContentValues args, String whereClause, String[] whereArgs) { // String whereClause = "id=?"; // String[] whereArgs = new String[] { String.valueOf(id) }; db.update(table, args, whereClause, whereArgs); }
/** * 更新数据 * * @param rowId 数据id * @param tableName 表名 * @param key 更新列名 * @param args 更新数据 * @return 是否更新成功 */ public boolean update(long rowId, String tableName, String key, ContentValues args) { return db.update(tableName, args, key + "=" + rowId, null) > 0; }