SQLiteConnection


public interface SQLiteConnection extends AutoCloseable

Known direct subclasses
SupportSQLiteConnection

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


SQLite connection definition.

A connection to a database is a resource that must be released once it is no longer needed via its close function.

See also Database Connection

Summary

Public methods

abstract void

Closes the database connection.

default boolean

Returns true if the connection has an active transaction, false otherwise.

abstract @NonNull SQLiteStatement

Prepares a new SQL statement.

abstract @NonNull SQLiteStatement

Prepares a new SQL statement asynchronously.

Extension functions

default final void

Executes a single SQL statement that returns no values.

default final void

Executes a single SQL statement asynchronously that returns no values.

default final @NonNull SQLiteStatement

Prepares a new SQL statement asynchronously.

Public methods

close

Added in 2.5.0
abstract void close()

Closes the database connection.

Once a connection is closed it should no longer be used. Calling this function on an already closed database connection is a no-op.

inTransaction

Added in 2.6.0
default boolean inTransaction()

Returns true if the connection has an active transaction, false otherwise.

prepare

Added in 2.5.0
abstract @NonNull SQLiteStatement prepare(@NonNull String sql)

Prepares a new SQL statement.

See also Compiling a SQL statement

Parameters
@NonNull String sql

the SQL statement to prepare

Returns
@NonNull SQLiteStatement

the prepared statement.

prepareAsync

abstract @NonNull SQLiteStatement prepareAsync(@NonNull String sql)

Prepares a new SQL statement asynchronously.

See also Compiling a SQL statement

Parameters
@NonNull String sql

the SQL statement to prepare

Returns
@NonNull SQLiteStatement

the prepared statement.

Extension functions

SQLite.execSQL

default final void SQLite.execSQL(@NonNull SQLiteConnection receiver, @NonNull String sql)

Executes a single SQL statement that returns no values.

SQLite.executeSQL

default final void SQLite.executeSQL(@NonNull SQLiteConnection receiver, @NonNull String sql)

Executes a single SQL statement asynchronously that returns no values.

On web targets this function is asynchronous while for non-web it is synchronous.

SQLite.prepare

default final @NonNull SQLiteStatement SQLite.prepare(@NonNull SQLiteConnection receiver, @NonNull String sql)

Prepares a new SQL statement asynchronously.

On web targets this function is asynchronous while for non-web it is synchronous.