Back to project page android-mvc-framework.
The source code is released under:
Apache License
If you think the Android project android-mvc-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.android_mvc.framework.db.transaction.todo; /*from w ww .j ava2s.c om*/ import android.database.sqlite.SQLiteDatabase; /** * SQLite???????????????????????????????????????????????????????TODO??? * @author id:language_and_engineering * */ public abstract class TxnScope { private boolean is_top_level = false; private SQLiteDatabase db; /** * ?????????????????????DB???????????????????????????????????? */ protected abstract void handleDB(); /** * ???? */ public TxnScope( SQLiteDatabase db, TxnScope upper_scope ) { this.db = db; if( upper_scope == null ) { this.is_top_level = true; } } /** * ????????????????? */ public void execute( TxnListener listener ) { try { manipulate_db(); listener.onComplete(); } catch( Exception e ) { // TODO: ???????????????????? // listener???????????????????????????????????????????????????? listener.onError( e ); } } /** * ??????????????????????????????????????????? */ public boolean execute() { try { manipulate_db(); return true; } catch( Exception e ) { // TODO: return false; } } /** * ??????????????????????DB?????????? */ private void manipulate_db() throws Exception { // NOTE: sqlite3.6.8???????????SQL????????????????????????????????????????? // ???????????????????????????????????????????????? // ????RDB????????????????????????????????Command?????????????????????????????? if( is_top_level ) db.beginTransaction(); try { handleDB(); if( is_top_level ) db.setTransactionSuccessful(); } catch( Exception e ) { throw e; } finally { if( is_top_level ) db.endTransaction(); } } /** * ?????????? * ?????????????????????????????????????????????????????? * ???????????????????????????????????????????????????? */ protected TxnScope getScope() { return this; } }