SQLiteConnection


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 functions

Unit

Closes the database connection.

Cmn
android
JS
Boolean

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

Cmn
android
JS
SQLiteStatement

Prepares a new SQL statement.

android
suspend SQLiteStatement

Prepares a new SQL statement asynchronously.

Cmn
JS

Extension functions

Unit

Executes a single SQL statement that returns no values.

android
suspend Unit

Executes a single SQL statement asynchronously that returns no values.

Cmn
android
JS
suspend SQLiteStatement

Prepares a new SQL statement asynchronously.

Cmn
android
JS

Public functions

close

fun close(): Unit

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

fun inTransaction(): Boolean

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

prepare

fun prepare(sql: String): SQLiteStatement

Prepares a new SQL statement.

See also Compiling a SQL statement

Parameters
sql: String

the SQL statement to prepare

Returns
SQLiteStatement

the prepared statement.

prepareAsync

suspend fun prepareAsync(sql: String): SQLiteStatement

Prepares a new SQL statement asynchronously.

See also Compiling a SQL statement

Parameters
sql: String

the SQL statement to prepare

Returns
SQLiteStatement

the prepared statement.

Extension functions

execSQL

fun SQLiteConnection.execSQL(sql: String): Unit

Executes a single SQL statement that returns no values.

executeSQL

suspend fun SQLiteConnection.executeSQL(sql: String): Unit

Executes a single SQL statement asynchronously that returns no values.

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

prepare

suspend fun SQLiteConnection.prepare(sql: String): SQLiteStatement

Prepares a new SQL statement asynchronously.

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