# SupportSQLiteConnection

Artifact: [androidx.sqlite:sqlite-framework](https://developer.android.com/jetpack/androidx/releases/sqlite) [View Source](https://cs.android.com/search?q=file:androidx/sqlite/driver/SupportSQLiteConnection.android.kt+class:androidx.sqlite.driver.SupportSQLiteConnection) Added in [2.6.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.6.0)

*** ** * ** ***


```
public final class SupportSQLiteConnection implements SQLiteConnection
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/sqlite/SQLiteConnection` implemented by `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteDatabase` and that uses the Android's SQLite through the `SupportSQLite` APIs.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/sqlite/driver/SupportSQLiteConnection#SupportSQLiteConnection(androidx.sqlite.db.SupportSQLiteDatabase)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteDatabase db)` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/sqlite/driver/SupportSQLiteConnection#close()()` Closes the database connection. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteDatabase` | `https://developer.android.com/reference/androidx/sqlite/driver/SupportSQLiteConnection#getDb()()` |
| `boolean` | `https://developer.android.com/reference/androidx/sqlite/driver/SupportSQLiteConnection#inTransaction()()` Returns true if the connection has an active transaction, false otherwise. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteStatement` | `https://developer.android.com/reference/androidx/sqlite/driver/SupportSQLiteConnection#prepare(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html sql)` Prepares a new SQL statement. |

## Public constructors

### SupportSQLiteConnection

Added in [2.6.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.6.0)

```
public SupportSQLiteConnection(@NonNull SupportSQLiteDatabase db)
```

## Public methods

### close

Added in [2.6.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.6.0)

```
public 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.

### getDb

Added in [2.6.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.6.0)

```
public final @NonNull SupportSQLiteDatabase getDb()
```

### inTransaction

```
public boolean inTransaction()
```

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

### prepare

Added in [2.6.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.6.0)

```
public @NonNull SQLiteStatement prepare(@NonNull String sql)
```

Prepares a new SQL statement.

See also [Compiling a SQL statement](https://www.sqlite.org/c3ref/prepare.html)

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html sql` | the SQL statement to prepare |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteStatement` | the prepared statement. |