Added in API level 27

Builder


class Builder
kotlin.Any
   ↳ android.database.sqlite.SQLiteDatabase.OpenParams.Builder

Builder for OpenParams.

Summary

Public constructors

Public methods
SQLiteDatabase.OpenParams.Builder
addOpenFlags(openFlags: Int)

Adds flags to control database access mode

SQLiteDatabase.OpenParams

Creates an instance of OpenParams with the options that were previously set on this builder

SQLiteDatabase.OpenParams.Builder
removeOpenFlags(openFlags: Int)

Removes database access mode flags

SQLiteDatabase.OpenParams.Builder

Set an optional factory class that is called to instantiate a cursor when query is called.

SQLiteDatabase.OpenParams.Builder

Sets DatabaseErrorHandler object to handle db corruption errors

SQLiteDatabase.OpenParams.Builder
setIdleConnectionTimeout(idleConnectionTimeoutMs: Long)

Sets the maximum number of milliseconds that SQLite connection is allowed to be idle before it is closed and removed from the pool.

SQLiteDatabase.OpenParams.Builder
setJournalMode(journalMode: String)

Sets journal mode to use.

SQLiteDatabase.OpenParams.Builder!
setLookasideConfig(slotSize: Int, slotCount: Int)

Configures lookaside memory allocator

SQLiteDatabase.OpenParams.Builder
setOpenFlags(openFlags: Int)

Sets flags to control database access mode

SQLiteDatabase.OpenParams.Builder

Sets synchronous mode

Public constructors

Builder

Added in API level 27
Builder()

Builder

Added in API level 27
Builder(params: SQLiteDatabase.OpenParams!)

Public methods

addOpenFlags

Added in API level 27
fun addOpenFlags(openFlags: Int): SQLiteDatabase.OpenParams.Builder

Adds flags to control database access mode

Parameters
openFlags Int: The new flags to add Value is either 0 or a combination of android.database.sqlite.SQLiteDatabase#OPEN_READWRITE, android.database.sqlite.SQLiteDatabase#OPEN_READONLY, android.database.sqlite.SQLiteDatabase#CREATE_IF_NECESSARY, android.database.sqlite.SQLiteDatabase#NO_LOCALIZED_COLLATORS, android.database.sqlite.SQLiteDatabase.NO_DOUBLE_QUOTED_STRS, and android.database.sqlite.SQLiteDatabase#ENABLE_WRITE_AHEAD_LOGGING
Return
SQLiteDatabase.OpenParams.Builder same builder instance for chaining multiple calls into a single statement This value cannot be null.

build

Added in API level 27
fun build(): SQLiteDatabase.OpenParams

Creates an instance of OpenParams with the options that were previously set on this builder

Return
SQLiteDatabase.OpenParams This value cannot be null.

removeOpenFlags

Added in API level 27
fun removeOpenFlags(openFlags: Int): SQLiteDatabase.OpenParams.Builder

Removes database access mode flags

Parameters
openFlags Int: Flags to remove Value is either 0 or a combination of android.database.sqlite.SQLiteDatabase#OPEN_READWRITE, android.database.sqlite.SQLiteDatabase#OPEN_READONLY, android.database.sqlite.SQLiteDatabase#CREATE_IF_NECESSARY, android.database.sqlite.SQLiteDatabase#NO_LOCALIZED_COLLATORS, android.database.sqlite.SQLiteDatabase.NO_DOUBLE_QUOTED_STRS, and android.database.sqlite.SQLiteDatabase#ENABLE_WRITE_AHEAD_LOGGING
Return
SQLiteDatabase.OpenParams.Builder same builder instance for chaining multiple calls into a single statement This value cannot be null.

setCursorFactory

Added in API level 27
fun setCursorFactory(cursorFactory: SQLiteDatabase.CursorFactory?): SQLiteDatabase.OpenParams.Builder

Set an optional factory class that is called to instantiate a cursor when query is called.

Parameters
cursorFactory SQLiteDatabase.CursorFactory?: instance This value may be null.
Return
SQLiteDatabase.OpenParams.Builder same builder instance for chaining multiple calls into a single statement This value cannot be null.

setErrorHandler

Added in API level 27
fun setErrorHandler(errorHandler: DatabaseErrorHandler?): SQLiteDatabase.OpenParams.Builder

Sets DatabaseErrorHandler object to handle db corruption errors

Parameters
errorHandler DatabaseErrorHandler?: This value may be null.
Return
SQLiteDatabase.OpenParams.Builder This value cannot be null.

setIdleConnectionTimeout

Added in API level 27
Deprecated in API level 29
fun setIdleConnectionTimeout(idleConnectionTimeoutMs: Long): SQLiteDatabase.OpenParams.Builder

Deprecated: DO NOT USE this method. See the javadoc for the details.

Sets the maximum number of milliseconds that SQLite connection is allowed to be idle before it is closed and removed from the pool.

DO NOT USE this method. This feature has negative side effects that are very hard to foresee.

A connection timeout allows the system to internally close a connection to a SQLite database after a given timeout, which is good for reducing app's memory consumption. However the side effect is it will reset all of SQLite's per-connection states, which are typically modified with a PRAGMA statement, and these states will not be restored when a connection is re-established internally, and the system does not provide a callback for an app to reconfigure a connection. This feature may only be used if an app relies on none of such per-connection states.

Parameters
idleConnectionTimeoutMs Long: timeout in milliseconds. Use Long.MAX_VALUE to allow unlimited idle connections. Value is 0 or greater
Return
SQLiteDatabase.OpenParams.Builder This value cannot be null.

setJournalMode

Added in API level 28
fun setJournalMode(journalMode: String): SQLiteDatabase.OpenParams.Builder

Sets journal mode to use.

Note: If journal mode is not set, the platform will use a manufactured-specified default which can vary across devices.

Parameters
journalMode String: Value is android.database.sqlite.SQLiteDatabase#JOURNAL_MODE_WAL, android.database.sqlite.SQLiteDatabase#JOURNAL_MODE_PERSIST, android.database.sqlite.SQLiteDatabase#JOURNAL_MODE_TRUNCATE, android.database.sqlite.SQLiteDatabase#JOURNAL_MODE_MEMORY, android.database.sqlite.SQLiteDatabase#JOURNAL_MODE_DELETE, or android.database.sqlite.SQLiteDatabase#JOURNAL_MODE_OFF This value cannot be null.
Return
SQLiteDatabase.OpenParams.Builder This value cannot be null.

setLookasideConfig

Added in API level 27
fun setLookasideConfig(
    slotSize: Int,
    slotCount: Int
): SQLiteDatabase.OpenParams.Builder!

Configures lookaside memory allocator

SQLite default settings will be used, if this method isn't called. Use setLookasideConfig(0,0) to disable lookaside

Note: Provided slotSize/slotCount configuration is just a recommendation. The system may choose different values depending on a device, e.g. lookaside allocations can be disabled on low-RAM devices

Parameters
slotSize Int: The size in bytes of each lookaside slot. Value is 0 or greater
slotCount Int: The total number of lookaside memory slots per database connection. Value is 0 or greater

setOpenFlags

Added in API level 27
fun setOpenFlags(openFlags: Int): SQLiteDatabase.OpenParams.Builder

Sets flags to control database access mode

Parameters
openFlags Int: The new flags to set Value is either 0 or a combination of android.database.sqlite.SQLiteDatabase#OPEN_READWRITE, android.database.sqlite.SQLiteDatabase#OPEN_READONLY, android.database.sqlite.SQLiteDatabase#CREATE_IF_NECESSARY, android.database.sqlite.SQLiteDatabase#NO_LOCALIZED_COLLATORS, android.database.sqlite.SQLiteDatabase.NO_DOUBLE_QUOTED_STRS, and android.database.sqlite.SQLiteDatabase#ENABLE_WRITE_AHEAD_LOGGING
Return
SQLiteDatabase.OpenParams.Builder same builder instance for chaining multiple calls into a single statement This value cannot be null.

setSynchronousMode

Added in API level 28
fun setSynchronousMode(syncMode: String): SQLiteDatabase.OpenParams.Builder

Sets synchronous mode

Note: If sync mode is not set, the platform will use a manufactured-specified default which can vary across devices.

Parameters
syncMode String: Value is android.database.sqlite.SQLiteDatabase#SYNC_MODE_EXTRA, android.database.sqlite.SQLiteDatabase#SYNC_MODE_FULL, android.database.sqlite.SQLiteDatabase#SYNC_MODE_NORMAL, or android.database.sqlite.SQLiteDatabase#SYNC_MODE_OFF This value cannot be null.
Return
SQLiteDatabase.OpenParams.Builder This value cannot be null.