本文整理汇总了Java中android.database.sqlite.SQLiteTransactionListener类的典型用法代码示例。如果您正苦于以下问题:Java SQLiteTransactionListener类的具体用法?Java SQLiteTransactionListener怎么用?Java SQLiteTransactionListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SQLiteTransactionListener类属于android.database.sqlite包,在下文中一共展示了SQLiteTransactionListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveTimetableCourses
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
@Override
public void saveTimetableCourses(final List<Course> courses) {
SQLiteDatabase db = mDbHelper.getWritableDatabase();
db.beginTransactionWithListener(new SQLiteTransactionListener() {
@Override
public void onBegin() {
}
@Override
public void onCommit() {
Log.d(tag, "save courses " + courses.size() + "commit successful");
}
@Override
public void onRollback() {
Log.d(tag, "save courses " + courses.size() + "rollback");
}
});
for (Course course : courses) {
db.insert(CoursePersistenceContract.CourseTimetableEntry.TABLE_NAME, null , convertTimetableCourseToCv(course));
}
db.setTransactionSuccessful();
db.endTransaction();
}
示例2: beginTransactionWithListener
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* NOTE: Not presently supported, will throw an UnsupportedOperationException
*/
@Override
public void beginTransactionWithListener(
SQLiteTransactionListener transactionListener) {
// TODO not supported in SQLCipher for Android
throw new UnsupportedOperationException("I kinna do it, cap'n!");
}
示例3: beginTransactionWithListenerNonExclusive
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* NOTE: Not presently supported, will throw an UnsupportedOperationException
*/
@Override
public void beginTransactionWithListenerNonExclusive(
SQLiteTransactionListener transactionListener) {
// TODO not supported in SQLCipher for Android
throw new UnsupportedOperationException("I kinna do it, cap'n!");
}
示例4: beginTransaction
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
private void beginTransaction(SQLiteTransactionListener transactionListener, int mode) {
acquireReference();
try {
getThreadSession().beginTransaction(mode, transactionListener,
getThreadDefaultConnectionFlags(false /*readOnly*/), null);
} finally {
releaseReference();
}
}
示例5: yieldTransactionUnchecked
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
private boolean yieldTransactionUnchecked(long sleepAfterYieldDelayMillis,
CancellationSignal cancellationSignal) {
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
}
if (!mConnectionPool.shouldYieldConnection(mConnection, mConnectionFlags)) {
return false;
}
final int transactionMode = mTransactionStack.mMode;
final SQLiteTransactionListener listener = mTransactionStack.mListener;
final int connectionFlags = mConnectionFlags;
endTransactionUnchecked(cancellationSignal, true); // might throw
if (sleepAfterYieldDelayMillis > 0) {
try {
Thread.sleep(sleepAfterYieldDelayMillis);
} catch (InterruptedException ex) {
// we have been interrupted, that's all we need to do
}
}
beginTransactionUnchecked(transactionMode, listener, connectionFlags,
cancellationSignal); // might throw
return true;
}
示例6: obtainTransaction
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
private Transaction obtainTransaction(int mode, SQLiteTransactionListener listener) {
Transaction transaction = mTransactionPool;
if (transaction != null) {
mTransactionPool = transaction.mParent;
transaction.mParent = null;
transaction.mMarkedSuccessful = false;
transaction.mChildFailed = false;
} else {
transaction = new Transaction();
}
transaction.mMode = mode;
transaction.mListener = listener;
return transaction;
}
示例7: beginTransactionWithListener
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
@Override
public void beginTransactionWithListener(SQLiteTransactionListener transactionListener) {
mDelegate.beginTransactionWithListener(transactionListener);
}
示例8: beginTransactionWithListenerNonExclusive
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
@Override
public void beginTransactionWithListenerNonExclusive(
SQLiteTransactionListener transactionListener) {
mDelegate.beginTransactionWithListenerNonExclusive(transactionListener);
}
示例9: beginTransactionUnchecked
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
private void beginTransactionUnchecked(int transactionMode,
SQLiteTransactionListener transactionListener, int connectionFlags,
CancellationSignal cancellationSignal) {
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
}
if (mTransactionStack == null) {
acquireConnection(null, connectionFlags, cancellationSignal); // might throw
}
try {
// Set up the transaction such that we can back out safely
// in case we fail part way.
if (mTransactionStack == null) {
// Execute SQL might throw a runtime exception.
switch (transactionMode) {
case TRANSACTION_MODE_IMMEDIATE:
mConnection.execute("BEGIN IMMEDIATE;", null,
cancellationSignal); // might throw
break;
case TRANSACTION_MODE_EXCLUSIVE:
mConnection.execute("BEGIN EXCLUSIVE;", null,
cancellationSignal); // might throw
break;
default:
mConnection.execute("BEGIN;", null, cancellationSignal); // might throw
break;
}
}
// Listener might throw a runtime exception.
if (transactionListener != null) {
try {
transactionListener.onBegin(); // might throw
} catch (RuntimeException ex) {
if (mTransactionStack == null) {
mConnection.execute("ROLLBACK;", null, cancellationSignal); // might throw
}
throw ex;
}
}
// Bookkeeping can't throw, except an OOM, which is just too bad...
Transaction transaction = obtainTransaction(transactionMode, transactionListener);
transaction.mParent = mTransactionStack;
mTransactionStack = transaction;
} finally {
if (mTransactionStack == null) {
releaseConnection(); // might throw
}
}
}
示例10: endTransactionUnchecked
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
private void endTransactionUnchecked(CancellationSignal cancellationSignal, boolean yielding) {
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
}
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;
}
}
示例11: beginTransactionWithListenerNonExclusive
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
@Override
public void beginTransactionWithListenerNonExclusive(
SQLiteTransactionListener transactionListener) {
mDelegate.beginTransactionWithListenerNonExclusive(transactionListener);
}
示例12: beginTransactionWithListener
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
@Override
public void beginTransactionWithListener(SQLiteTransactionListener transactionListener) {
throw new UnsupportedOperationException();
}
示例13: beginTransactionWithListenerNonExclusive
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
@Override
public void beginTransactionWithListenerNonExclusive(SQLiteTransactionListener transactionListener) {
throw new UnsupportedOperationException();
}
示例14: beginTransaction
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
/**
* Begins a transaction.
* <p>
* Transactions may nest. If the transaction is not in progress,
* then a database connection is obtained and a new transaction is started.
* Otherwise, a nested transaction is started.
* </p><p>
* Each call to {@link #beginTransaction} must be matched exactly by a call
* to {@link #endTransaction}. To mark a transaction as successful,
* call {@link #setTransactionSuccessful} before calling {@link #endTransaction}.
* If the transaction is not successful, or if any of its nested
* transactions were not successful, then the entire transaction will
* be rolled back when the outermost transaction is ended.
* </p>
*
* @param transactionMode The transaction mode. One of: {@link #TRANSACTION_MODE_DEFERRED},
* {@link #TRANSACTION_MODE_IMMEDIATE}, or {@link #TRANSACTION_MODE_EXCLUSIVE}.
* Ignored when creating a nested transaction.
* @param transactionListener The transaction listener, or null if none.
* @param connectionFlags The connection flags to use if a connection must be
* acquired by this operation. Refer to {@link SQLiteConnectionPool}.
* @param cancellationSignal A signal to cancel the operation in progress, or null if none.
*
* @throws IllegalStateException if {@link #setTransactionSuccessful} has already been
* called for the current transaction.
* @throws SQLiteException if an error occurs.
* @throws OperationCanceledException if the operation was canceled.
*
* @see #setTransactionSuccessful
* @see #yieldTransaction
* @see #endTransaction
*/
public void beginTransaction(int transactionMode,
SQLiteTransactionListener transactionListener,
int connectionFlags,
CancellationSignal cancellationSignal) {
throwIfTransactionMarkedSuccessful();
beginTransactionUnchecked(transactionMode, transactionListener, connectionFlags,
cancellationSignal);
}
示例15: beginTransactionWithListenerDeferred
import android.database.sqlite.SQLiteTransactionListener; //导入依赖的package包/类
/**
* Begins a transaction in DEFERRED mode.
*
* @param transactionListener listener that should be notified when the transaction begins,
* commits, or is rolled back, either explicitly or by a call to
* {@link #yieldIfContendedSafely}.
*/
public void beginTransactionWithListenerDeferred(
SQLiteTransactionListener transactionListener) {
beginTransaction(transactionListener, SQLiteSession.TRANSACTION_MODE_DEFERRED);
}