1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| SQLiteDatabase db = mDbHelper.getWritableDatabase(); try { db.beginTransaction();
String position = mode.getPosition().ordinal() + ""; String action = mode.getAction().ordinal() + "";
ContentValues values = new ContentValues(); values.put("color", mode.getColor()); values.put("used", mode.isUsed() ? 1 : 0); values.put("level", mode.getLevel()); values.put("time", mode.getTime());
db.update(TABLE_NAME, values, " position=? and action = ? ", new String[]{position, action}); values.clear();
db.setTransactionSuccessful(); } catch (Exception e) { e.printStackTrace(); } finally { db.endTransaction(); db.close(); }
|