类android.database.DefaultDatabaseErrorHandler源码实例Demo

下面列出了怎么用android.database.DefaultDatabaseErrorHandler的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: android_9.0.0_r45   文件: SQLiteDatabase.java
private SQLiteDatabase(final String path, final int openFlags,
        CursorFactory cursorFactory, DatabaseErrorHandler errorHandler,
        int lookasideSlotSize, int lookasideSlotCount, long idleConnectionTimeoutMs,
        String journalMode, String syncMode) {
    mCursorFactory = cursorFactory;
    mErrorHandler = errorHandler != null ? errorHandler : new DefaultDatabaseErrorHandler();
    mConfigurationLocked = new SQLiteDatabaseConfiguration(path, openFlags);
    mConfigurationLocked.lookasideSlotSize = lookasideSlotSize;
    mConfigurationLocked.lookasideSlotCount = lookasideSlotCount;
    // Disable lookaside allocator on low-RAM devices
    if (ActivityManager.isLowRamDeviceStatic()) {
        mConfigurationLocked.lookasideSlotCount = 0;
        mConfigurationLocked.lookasideSlotSize = 0;
    }
    long effectiveTimeoutMs = Long.MAX_VALUE;
    // Never close idle connections for in-memory databases
    if (!mConfigurationLocked.isInMemoryDb()) {
        // First, check app-specific value. Otherwise use defaults
        // -1 in idleConnectionTimeoutMs indicates unset value
        if (idleConnectionTimeoutMs >= 0) {
            effectiveTimeoutMs = idleConnectionTimeoutMs;
        } else if (DEBUG_CLOSE_IDLE_CONNECTIONS) {
            effectiveTimeoutMs = SQLiteGlobal.getIdleConnectionTimeout();
        }
    }
    mConfigurationLocked.idleConnectionTimeoutMs = effectiveTimeoutMs;
    mConfigurationLocked.journalMode = journalMode;
    mConfigurationLocked.syncMode = syncMode;
    if (!SQLiteGlobal.isCompatibilityWalSupported() || (
            SQLiteCompatibilityWalFlags.areFlagsSet() && !SQLiteCompatibilityWalFlags
                    .isCompatibilityWalSupported())) {
        mConfigurationLocked.openFlags |= DISABLE_COMPATIBILITY_WAL;
    }
}
 
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static PreferencesSQLiteOpenHelper newInstancePostHoneycomb(Context context) {
    return new PreferencesSQLiteOpenHelper(context, new DefaultDatabaseErrorHandler());
}