首页 > 移动平台 > 详细

android第十五步在SQLite中使用事物

时间:2014-03-18 07:58:33      阅读:427      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
        SQLiteDatabase db = dbOpenHelper.getWritableDatabase();//数据库操作实例
        db.beginTransaction(); //开始事务
        try{
        db.execSQL("update person set amount= amount-10 where personid=1");
        db.execSQL("update person set amount= amount+10 where personid=2");
        db.setTransactionSuccessful();//设置事务标志为true
        }finally{
            db.endTransaction();//结束事务 事务的提交或回滚使用事务的标志决定的,如果事务表示为TRUE就提交否则就回滚,默认情况下事务的标志位FALSE
        }
bubuko.com,布布扣

android第十五步在SQLite中使用事物,布布扣,bubuko.com

android第十五步在SQLite中使用事物

原文:http://www.cnblogs.com/zyldream/p/3604847.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!