Example usage for android.database.sqlite SQLiteConnection reconfigure

List of usage examples for android.database.sqlite SQLiteConnection reconfigure

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteConnection reconfigure.

Prototype

void reconfigure(SQLiteDatabaseConfiguration configuration) 

Source Link

Usage

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

private void reconfigureAllConnectionsLocked() {
    if (mAvailablePrimaryConnection != null) {
        try {/*  w ww  .j  a  v  a 2  s  .  c  om*/
            mAvailablePrimaryConnection.reconfigure(mConfiguration); // might throw
        } catch (RuntimeException ex) {
            Log.e(TAG, "Failed to reconfigure available primary connection, closing it: "
                    + mAvailablePrimaryConnection, ex);
            closeConnectionAndLogExceptionsLocked(mAvailablePrimaryConnection);
            mAvailablePrimaryConnection = null;
        }
    }

    int count = mAvailableNonPrimaryConnections.size();
    for (int i = 0; i < count; i++) {
        final SQLiteConnection connection = mAvailableNonPrimaryConnections.get(i);
        try {
            connection.reconfigure(mConfiguration); // might throw
        } catch (RuntimeException ex) {
            Log.e(TAG, "Failed to reconfigure available non-primary connection, closing it: " + connection, ex);
            closeConnectionAndLogExceptionsLocked(connection);
            mAvailableNonPrimaryConnections.remove(i--);
            count -= 1;
        }
    }

    markAcquiredConnectionsLocked(AcquiredConnectionStatus.RECONFIGURE);
}

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

private boolean recycleConnectionLocked(SQLiteConnection connection, AcquiredConnectionStatus status) {
    if (status == AcquiredConnectionStatus.RECONFIGURE) {
        try {// w w w  .ja  va  2  s .  c om
            connection.reconfigure(mConfiguration); // might throw
        } catch (RuntimeException ex) {
            Log.e(TAG, "Failed to reconfigure released connection, closing it: " + connection, ex);
            status = AcquiredConnectionStatus.DISCARD;
        }
    }
    if (status == AcquiredConnectionStatus.DISCARD) {
        closeConnectionAndLogExceptionsLocked(connection);
        return false;
    }
    return true;
}