BundledSQLiteDriver


public final class BundledSQLiteDriver implements SQLiteDriver


A SQLiteDriver that uses a bundled version of SQLite included as a native component of this library.

The bundled SQLite used by this driver is compiled in multi-thread mode which means connections opened by the driver are NOT thread-safe. If multiple connections are desired, then a connection pool is required in order for the connections be used in a multi-thread and concurrent environment. If only a single connection is needed then a thread-safe connection can be opened by using the SQLITE_OPEN_FULLMUTEX flag. If the connection usage is exclusively single threaded, then no additional configuration is required.

Summary

Public constructors

Public methods

final void

Registers a dynamically-linked SQLite extension to load for every subsequent connection opened with this driver.

final void
addExtension(@NonNull String fileName, @NonNull String entryPoint)

Registers a dynamically-linked SQLite extension to load for every subsequent connection opened with this driver.

boolean

Identifies whether the driver has an internal connection pool or not.

@NonNull SQLiteConnection
open(@NonNull String fileName)

Opens a new database connection.

final @NonNull SQLiteConnection
open(@NonNull String fileName, int flags)

Opens a new database connection.

Inherited methods

From androidx.sqlite.SQLiteDriver
boolean

Identifies whether the driver has an internal connection pool or not.

Public constructors

BundledSQLiteDriver

Added in 2.5.0
public BundledSQLiteDriver()

BundledSQLiteDriver

Added in 2.5.0
public BundledSQLiteDriver()

Public methods

addExtension

Added in 2.6.0-rc01
public final void addExtension(@NonNull String fileName)

Registers a dynamically-linked SQLite extension to load for every subsequent connection opened with this driver.

The extension is loaded by SQLite in a platform-specific way. SQLite will attempt to open the file using (e.g. dlopen on POSIX) and look up a native function responsible for initializing the extension. SQLite will derive the entry function from the file name.

It is the developer's responsibility to ensure that the library is actually available with the app. If the file is not available when a connection from this driver is opened, then an androidx.sqlite.SQLiteException will be thrown during open.

See also: Load an extension

Parameters
@NonNull String fileName

The path to the extension to load. A given file can only be added as an extension once.

addExtension

Added in 2.6.0-rc01
public final void addExtension(@NonNull String fileName, @NonNull String entryPoint)

Registers a dynamically-linked SQLite extension to load for every subsequent connection opened with this driver.

The extension is loaded by SQLite in a platform-specific way. SQLite will attempt to open the file using (e.g. dlopen on POSIX) and look up a native function responsible for initializing the extension. The entryPoint defines the function name to be invoke to initialize the extension.

It is the developer's responsibility to ensure that the library is actually available with the app. If the file is not available when a connection from this driver is opened, then an androidx.sqlite.SQLiteException will be thrown during open.

See also: Load an extension

Parameters
@NonNull String fileName

The path to the extension to load. A given file can only be added as an extension once.

@NonNull String entryPoint

The function name to serve as entry point in the loaded extension library.

hasConnectionPool

public boolean hasConnectionPool()

Identifies whether the driver has an internal connection pool or not.

A driver with an internal pool should be capable of opening connections that are safe to be used in a multi-thread and concurrent environment whereas a driver that does not have an internal pool will require the application to manage connections in a thread-safe manner. A driver might not report containing a connection pool but might still be safe to be used in a multi-thread environment, such behavior will depend on the driver implementation.

The value returned should be used as a signal to higher abstractions in order to determine if the driver and its connections should be managed by an external connection pool or not.

open

Added in 2.5.0
public @NonNull SQLiteConnection open(@NonNull String fileName)

Opens a new database connection.

To open an in-memory database use the special name :memory: as the fileName.

Parameters
@NonNull String fileName

Name of the database file.

Returns
@NonNull SQLiteConnection

the database connection.

open

Added in 2.5.0
public final @NonNull SQLiteConnection open(@NonNull String fileName, int flags)

Opens a new database connection.

See also Opening A New Database Connection

Parameters
@NonNull String fileName

Name of the database file.

int flags

Connection open flags.

Returns
@NonNull SQLiteConnection

the database connection.