Example usage for android.database.sqlite SQLiteTransactionListener onCommit

List of usage examples for android.database.sqlite SQLiteTransactionListener onCommit

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteTransactionListener onCommit.

Prototype

void onCommit();

Source Link

Document

Called immediately before commiting the transaction.

Usage

From source file:io.requery.android.database.sqlite.SQLiteSession.java

private void endTransactionUnchecked(CancellationSignal cancellationSignal, boolean yielding) {
    if (cancellationSignal != null) {
        cancellationSignal.throwIfCanceled();
    }/*from   w  w w .  java2 s . c  om*/

    final Transaction top = mTransactionStack;
    boolean successful = (top.mMarkedSuccessful || yielding) && !top.mChildFailed;

    RuntimeException listenerException = null;
    final SQLiteTransactionListener listener = top.mListener;
    if (listener != null) {
        try {
            if (successful) {
                listener.onCommit(); // might throw
            } else {
                listener.onRollback(); // might throw
            }
        } catch (RuntimeException ex) {
            listenerException = ex;
            successful = false;
        }
    }

    mTransactionStack = top.mParent;
    recycleTransaction(top);

    if (mTransactionStack != null) {
        if (!successful) {
            mTransactionStack.mChildFailed = true;
        }
    } else {
        try {
            if (successful) {
                mConnection.execute("COMMIT;", null, cancellationSignal); // might throw
            } else {
                mConnection.execute("ROLLBACK;", null, cancellationSignal); // might throw
            }
        } finally {
            releaseConnection(); // might throw
        }
    }

    if (listenerException != null) {
        throw listenerException;
    }
}