SupportSQLiteDriver


public final class SupportSQLiteDriver implements SQLiteDriver


A SQLiteDriver implemented by androidx.sqlite.db.SupportSQLiteOpenHelper and that uses the Android's SQLite through the SupportSQLite APIs.

This driver internally has a connection pool and a opened connection from it is safe to be used in a multi-thread and concurrent environment.

This driver can only open connections whose fileName match the given openHelper database name (SupportSQLiteOpenHelper.databaseName) or :memory: if the openHelper was configured with a null name, indicating an in-memory database.

Summary

Public constructors

Public methods

boolean

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

@NonNull SupportSQLiteConnection
open(@NonNull String fileName)

Opens a new database connection.

Public constructors

SupportSQLiteDriver

Added in 2.6.0-alpha01
public SupportSQLiteDriver(@NonNull SupportSQLiteOpenHelper openHelper)

Public methods

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.6.0-alpha01
public @NonNull SupportSQLiteConnection 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 SupportSQLiteConnection

the database connection.