「Android」複数のSQL構文は一つのトランザクションに実行するコード

Javaコード
//トランザクションテスト
public void payment()
{
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
//トランザクション開始
db.beginTransaction();
try
{
db.execSQL(“update employee set amount=amount-10 where employeeid=?", new Object[]{1});
db.execSQL(“update employee set amount=amount+10 where employeeid=?", new Object[]{2});
//トランザクション成功
db.setTransactionSuccessful();
}
catch(Exception e){
throw(e);
}
finally
{
//トランザクション終了
db.endTransaction();
}
}

Android

Posted by arkgame