Skip to content

Most visited

Recently visited

navigation

SQLiteDatabase.OpenParams.Builder

public static final class SQLiteDatabase.OpenParams.Builder
extends Object

java.lang.Object
   ↳ android.database.sqlite.SQLiteDatabase.OpenParams.Builder


Builder for SQLiteDatabase.OpenParams.

Summary

Public constructors

SQLiteDatabase.OpenParams.Builder()
SQLiteDatabase.OpenParams.Builder(SQLiteDatabase.OpenParams params)

Public methods

SQLiteDatabase.OpenParams.Builder addOpenFlags(int openFlags)

Adds flags to control database access mode

SQLiteDatabase.OpenParams build()

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

SQLiteDatabase.OpenParams.Builder removeOpenFlags(int openFlags)

Removes database access mode flags

SQLiteDatabase.OpenParams.Builder setCursorFactory(SQLiteDatabase.CursorFactory cursorFactory)

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

SQLiteDatabase.OpenParams.Builder setErrorHandler(DatabaseErrorHandler errorHandler)

Sets DatabaseErrorHandler object to handle db corruption errors

SQLiteDatabase.OpenParams.Builder setIdleConnectionTimeout(long idleConnectionTimeoutMs)

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 setLookasideConfig(int slotSize, int slotCount)

Configures lookaside memory allocator

SQLite default settings will be used, if this method isn't called.

SQLiteDatabase.OpenParams.Builder setOpenFlags(int openFlags)

Sets flags to control database access mode

Inherited methods

From class java.lang.Object

Public constructors

SQLiteDatabase.OpenParams.Builder

added in API level 27
SQLiteDatabase.OpenParams.Builder ()

SQLiteDatabase.OpenParams.Builder

added in API level 27
SQLiteDatabase.OpenParams.Builder (SQLiteDatabase.OpenParams params)

Parameters
params SQLiteDatabase.OpenParams

Public methods

addOpenFlags

added in API level 27
SQLiteDatabase.OpenParams.Builder addOpenFlags (int openFlags)

Adds flags to control database access mode

Parameters
openFlags int: The new flags to add

Value is either 0 or combination of OPEN_READWRITE, OPEN_READONLY, CREATE_IF_NECESSARY, NO_LOCALIZED_COLLATORS or ENABLE_WRITE_AHEAD_LOGGING.

Returns
SQLiteDatabase.OpenParams.Builder same builder instance for chaining multiple calls into a single statement

This value will never be null.

build

added in API level 27
SQLiteDatabase.OpenParams build ()

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

Returns
SQLiteDatabase.OpenParams

This value will never be null.

removeOpenFlags

added in API level 27
SQLiteDatabase.OpenParams.Builder removeOpenFlags (int openFlags)

Removes database access mode flags

Parameters
openFlags int: Flags to remove

Value is either 0 or combination of OPEN_READWRITE, OPEN_READONLY, CREATE_IF_NECESSARY, NO_LOCALIZED_COLLATORS or ENABLE_WRITE_AHEAD_LOGGING.

Returns
SQLiteDatabase.OpenParams.Builder same builder instance for chaining multiple calls into a single statement

This value will never be null.

setCursorFactory

added in API level 27
SQLiteDatabase.OpenParams.Builder setCursorFactory (SQLiteDatabase.CursorFactory cursorFactory)

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.

Returns
SQLiteDatabase.OpenParams.Builder same builder instance for chaining multiple calls into a single statement

This value will never be null.

setErrorHandler

added in API level 27
SQLiteDatabase.OpenParams.Builder setErrorHandler (DatabaseErrorHandler errorHandler)

Sets DatabaseErrorHandler object to handle db corruption errors

Parameters
errorHandler DatabaseErrorHandler

This value may be null.

Returns
SQLiteDatabase.OpenParams.Builder

This value will never be null.

setIdleConnectionTimeout

added in API level 27
SQLiteDatabase.OpenParams.Builder setIdleConnectionTimeout (long idleConnectionTimeoutMs)

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

Parameters
idleConnectionTimeoutMs long: timeout in milliseconds. Use MAX_VALUE to allow unlimited idle connections.

Returns
SQLiteDatabase.OpenParams.Builder

This value will never be null.

setLookasideConfig

added in API level 27
SQLiteDatabase.OpenParams.Builder setLookasideConfig (int slotSize, 
                int slotCount)

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.

slotCount int: The total number of lookaside memory slots per database connection.

Returns
SQLiteDatabase.OpenParams.Builder

setOpenFlags

added in API level 27
SQLiteDatabase.OpenParams.Builder setOpenFlags (int openFlags)

Sets flags to control database access mode

Parameters
openFlags int: The new flags to set

Value is either 0 or combination of OPEN_READWRITE, OPEN_READONLY, CREATE_IF_NECESSARY, NO_LOCALIZED_COLLATORS or ENABLE_WRITE_AHEAD_LOGGING.

Returns
SQLiteDatabase.OpenParams.Builder same builder instance for chaining multiple calls into a single statement

This value will never be null.

See also:

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)