如何回滚在Android上的事务? [英] How to roll back a transaction on Android?
本文介绍了如何回滚在Android上的事务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是标准的成语进行交易:
Here is the standard idiom for transactions:
db.beginTransaction();
try {
...
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
我想添加一个catch块,我想发出一个回滚。它是可能的,而且在所有我需要它?
I want to add a catch block, and I want to issue a rollback. Is it possible, and at all do I need it?
推荐答案
您不需要它。
如果有一个异常的 ...
在上面code时,code你已经有了将回滚事务。该终于{}
的捕获(块后执行){}
块。
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.
这篇关于如何回滚在Android上的事务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文