开发者

How to roll back a transaction on Android?

Here is the standard idiom for transactions:

   db.beginTransact开发者_开发百科ion();
   try {
     ...
     db.setTransactionSuccessful();
   } finally {
     db.endTransaction();
   }

I want to add a catch block, and I want to issue a rollback. Is it possible, and at all do I need it?


You do not need it.

If there is an exception in the ... in your above code, the code you already have will roll back the transaction. The finally {} block is executed after the catch() {} block.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜