Java Code Examples for android.database.sqlite.SQLiteDatabase#isDbLockedByCurrentThread()

The following examples show how to use android.database.sqlite.SQLiteDatabase#isDbLockedByCurrentThread() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * Completes the transaction, ending the DB transactions for all associated databases.
 *
 * @param callerIsBatch whether this is being performed in the context of a batch operation.
 *                      If it is not, and the transaction is marked as batch, this call is
 *                      a no-op.
 */
void finish(boolean callerIsBatch) {
	if (!mBatch || callerIsBatch) {
		for (SQLiteDatabase db : mDatabasesForTransaction) {
			// If an exception was thrown while yielding, it's possible that we no longer have
			// a lock on this database, so we need to check before attempting to end its
			// transaction. Otherwise, we should always expect to be in a transaction (and will
			// throw an exception if this is not the case).
			if (mYieldFailed && !db.isDbLockedByCurrentThread()) {
				// We no longer hold the lock, so don't do anything with this database.
				continue;
			}
			db.endTransaction();
		}
		mDatabasesForTransaction.clear();
		mDatabaseTagMap.clear();
		mIsDirty = false;
	}
}
 
Example 2
Source Project: Twire   File: Service.java    License: GNU General Public License v3.0 4 votes vote down vote up
private static boolean isDbSafe(SQLiteDatabase db) {
    return db.isOpen() && !db.isReadOnly() && !db.isDbLockedByCurrentThread();
}
 
Example 3
private static boolean isDbSafe(SQLiteDatabase db) {
    return db.isOpen() && !db.isReadOnly() && !db.isDbLockedByCurrentThread();
}