Sqlite

The androidx.sqlite library contains abstract interfaces along with basic implementations which can be used to build your own libraries that access SQLite.

You might want to consider using the Room library, which provides an abstraction layer over SQLite to allow for more robust database access while harnessing the full power of SQLite.

Latest Update Stable Release Release Candidate Beta Release Alpha Release
October 2, 2024 2.4.0 - - 2.5.0-alpha09

Declaring dependencies

To add a dependency on SQLite, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

Groovy

dependencies {
    def sqlite_version = "2.4.0"

    // Java language implementation
    implementation "androidx.sqlite:sqlite:$sqlite_version"

    // Kotlin
    implementation "androidx.sqlite:sqlite-ktx:$sqlite_version"

    // Implementation of the AndroidX SQLite interfaces via the Android framework APIs.
    implementation "androidx.sqlite:sqlite-framework:$sqlite_version"
}

Kotlin

dependencies {
    val sqlite_version = "2.4.0"

    // Java language implementation
    implementation("androidx.sqlite:sqlite:$sqlite_version")

    // Kotlin
    implementation("androidx.sqlite:sqlite-ktx:$sqlite_version")

    // Implementation of the AndroidX SQLite interfaces via the Android framework APIs.
    implementation("androidx.sqlite:sqlite-framework:$sqlite_version")
}

For more information about dependencies, see Add build dependencies.

Feedback

Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

Version 2.5

Version 2.5.0-alpha09

October 2, 2024

androidx.sqlite:sqlite-*:2.5.0-alpha09 is released. Version 2.5.0-alpha09 contains these commits.

Version 2.5.0-alpha08

September 18, 2024

androidx.sqlite:sqlite-*:2.5.0-alpha08 is released. Version 2.5.0-alpha08 contains these commits.

Version 2.5.0-alpha07

August 21, 2024

androidx.sqlite:sqlite-*:2.5.0-alpha07 is released. Version 2.5.0-alpha07 contains these commits.

New Features

  • Add support for Linux ARM 64 in JVM / Desktop targets. (b/358045505)

Version 2.5.0-alpha06

August 7, 2024

androidx.sqlite:sqlite-*:2.5.0-alpha06 is released. Version 2.5.0-alpha06 contains these commits.

New Features

Version 2.5.0-alpha05

July 10, 2024

androidx.sqlite:sqlite-*:2.5.0-alpha05 is released. Version 2.5.0-alpha05 contains these commits.

API Changes

  • Renamed SQLiteKt to SQLite and BundledSQLiteKt to BundledSQLite. (I8b501)

Version 2.5.0-alpha04

June 12, 2024

androidx.sqlite:sqlite-*:2.5.0-alpha04 is released. Version 2.5.0-alpha04 contains these commits.

API Changes

  • Added an open() overload API to BundledSQLiteDriver to pass open flags when opening a database connection. Useful for opening a database in read-only mode or using the serialized thread safe mode instead of the multi-thread mode bundled SQLite is compiled with (b/340949940).

Bug Fixes

  • Fixed a linking issue in the Bundled SQLite Driver that would cause UnsatisfiedLinkError to be thrown due to missing atomic symbols in Android devices with an ARM32. (b/341639198)
  • Fixed an issue in the drivers where binding a zero-length byte array into a column would lead to a null value when reading from it.

Version 2.5.0-alpha03

May 29, 2024

androidx.sqlite:sqlite-*:2.5.0-alpha03 is released. Version 2.5.0-alpha03 contains these commits.

Bug Fixes

  • Fix an issue with the BundledSQLiteDriver where databases created with it would contain the C null terminator character. (b/340822359)

Version 2.5.0-alpha02

May 14, 2024

androidx.sqlite:sqlite-*:2.5.0-alpha02 is released with no significant changes since 2.5.0-alpha01 . Version 2.5.0-alpha02 contains these commits.

Version 2.5.0-alpha01

May 1, 2024

androidx.sqlite:sqlite-*:2.5.0-alpha01 is released. Version 2.5.0-alpha01 contains these commits.

New Features

  • Kotlin Multi-Platform (KMP) Support: With the release of Room 2.7.0-alpha01 which is the first release of Room KMP, the SQLite APIs that enable Room to be KMP have also been updated. The package andriodx.sqlite contains three interfaces that define low-level SQLite APIs: SQLiteDriver, SQLiteConnection and SQLiteStatement. The artifact androidx.sqlite:sqlite-framework offers implementation of the interfaces for Android and iOS Natively, while androidx.sqlite:sqlite-bundled offers an implementation that uses SQLite compiled from source (also known as “bundled SQLite”). For more information about the SQLite Driver API refer to the official SQLite KMP documentation.

Version 2.4

Version 2.4.0

October 18, 2023

androidx.sqlite:sqlite:2.4.0, androidx.sqlite:sqlite-framework:2.4.0, and androidx.sqlite:sqlite-ktx:2.4.0 are released. Version 2.4.0 contains these commits.

Important changes since 2.3.0

  • Various bug fixes have been added.

Version 2.4.0-rc01

September 20, 2023

androidx.sqlite:sqlite:2.4.0-rc01, androidx.sqlite:sqlite-framework:2.4.0-rc01, and androidx.sqlite:sqlite-ktx:2.4.0-rc01 are released. Version 2.4.0-rc01 contains these commits.

Version 2.4.0-beta01

August 23, 2023

androidx.sqlite:sqlite:2.4.0-beta01, androidx.sqlite:sqlite-framework:2.4.0-beta01, and androidx.sqlite:sqlite-ktx:2.4.0-beta01 are released. Version 2.4.0-beta01 contains these commits.

Version 2.4.0-alpha03

August 9, 2023

androidx.sqlite:sqlite:2.4.0-alpha03, androidx.sqlite:sqlite-framework:2.4.0-alpha03, and androidx.sqlite:sqlite-ktx:2.4.0-alpha03 are released. Version 2.4.0-alpha03 contains these commits.

Version 2.4.0-alpha02

June 21, 2023

androidx.sqlite:sqlite:2.4.0-alpha02, androidx.sqlite:sqlite-framework:2.4.0-alpha02, and androidx.sqlite:sqlite-ktx:2.4.0-alpha02 are released with no changes. Version 2.4.0-alpha02 contains these commits.

Version 2.4.0-alpha01

March 22, 2023

androidx.sqlite:sqlite:2.4.0-alpha01, androidx.sqlite:sqlite-framework:2.4.0-alpha01, and androidx.sqlite:sqlite-ktx:2.4.0-alpha01 are released. Version 2.4.0-alpha01 contains these commits.

Bug Fixes

  • Fixed a NullPointerException that could occur in SupportSQLiteQueryBuilder. (5df8698)

Version 2.3.1

Version 2.3.1

March 22, 2023

androidx.sqlite:sqlite:2.3.1, androidx.sqlite:sqlite-framework:2.3.1, and androidx.sqlite:sqlite-ktx:2.3.1 are released. Version 2.3.1 contains these commits.

Bug Fixes

  • Avoid a framework issue where SQL queries would not get invalidated after a schema change during migrations. FrameworkSupportSQLiteOpenHelper will now set the minimum SQL statement cache during migrations to avoid the problem. (0ad2a8f)
  • Fixed an issue where the cache directory might not be available to use for SupportSQLiteLock, thus a null File must be gracefully handled. (9d177dc)
  • Fixed an issue where attachedDbs was not returning the full list of attached databases. (5f008e1)

Version 2.3.0

Version 2.3.0

January 11, 2023

androidx.sqlite:sqlite:2.3.0, androidx.sqlite:sqlite-framework:2.3.0, and androidx.sqlite:sqlite-ktx:2.3.0 are released. Version 2.3.0 contains these commits.

Important changes since 2.2.0

  • The library group androidx.sqlite sources has been converted from Java to Kotlin. Be aware that because androidx.sqlite had some missing nullability annotations you might experience source incompatibility errors if your sources are in Kotlin and the code was inferring the wrong nullability. Moreover, certain getter methods were converted to properties requiring the property access syntax on Kotlin files. Please file a bug if there are any significant incompatibilities. (b/240707042)
  • Add an API in SupportSQLite's configuration to allow data loss during the recovery mechanism. (I1b830, b/215592732)
  • Added API for multi-process lock and usage at the FrameworkSQLite* level, to protect multi-process 1st time database creation and migrations. (Ied267, b/193182592)

Version 2.3.0-rc01

December 7, 2022

androidx.sqlite:sqlite:2.3.0-rc01, androidx.sqlite:sqlite-framework:2.3.0-rc01, and androidx.sqlite:sqlite-ktx:2.3.0-rc01 are released. Version 2.3.0-rc01 contains these commits.

Bug Fixes

  • Resolving NPE issue in SupportSQLiteQueryBuilder for nullable columns. (Ica8f5)

Version 2.3.0-beta02

November 9, 2022

androidx.sqlite:sqlite:2.3.0-beta02, androidx.sqlite:sqlite-framework:2.3.0-beta02, and androidx.sqlite:sqlite-ktx:2.3.0-beta02 are released. Version 2.3.0-beta02 contains these commits.

  • Fix various APIs that take query arguments from invariant (Array<Any?>) to contravariant (Array<out Any?>) to match Java’s array behavior. (b/253531073)

Version 2.3.0-beta01

October 5, 2022

androidx.sqlite:sqlite:2.3.0-beta01, androidx.sqlite:sqlite-framework:2.3.0-beta01, and androidx.sqlite:sqlite-ktx:2.3.0-beta01 are released. Version 2.3.0-beta01 contains these commits.

API Changes

  • All of android.sqlite sources have been converted from Java to Kotlin. b/240707042
  • One notable change of the conversion is that the following getter functions have become properties:
    • In SupportSQLiteDatabase:
    • attachedDbs
    • isDatabaseIntegrityOk
    • isDbLockedByCurrentThread
    • isOpen
    • isReadOnly
    • isWriteAheadLoggingEnabled
    • maximumSize
    • pageSize
    • path
    • version
    • In SupportSQLiteOpenHelper:
    • databaseName
    • readableDatabase
    • writableDatabase

Version 2.3.0-alpha05

August 24, 2022

androidx.sqlite:sqlite:2.3.0-alpha05, androidx.sqlite:sqlite-framework:2.3.0-alpha05, and androidx.sqlite:sqlite-ktx:2.3.0-alpha05 are released. Version 2.3.0-alpha05 contains these commits.

API Changes

  • The library group androidx.sqlite sources has been converted from Java to Kotlin. Be aware that because androidx.sqlite had some missing nullability annotations you might experience source incompatibility errors if your sources are in Kotlin and the code was inferring the wrong nullability. Please file a bug if there are any significant incompatibility. (b/240707042)

Version 2.3.0-alpha04

August 10, 2022

androidx.sqlite:sqlite:2.3.0-alpha04, androidx.sqlite:sqlite-framework:2.3.0-alpha04, and androidx.sqlite:sqlite-ktx:2.3.0-alpha04 are released. Version 2.3.0-alpha04 contains these commits.

API Changes

  • Updated nullability (I29fbd)

Version 2.3.0-alpha03

June 1, 2022

androidx.sqlite:sqlite:2.3.0-alpha03, androidx.sqlite:sqlite-framework:2.3.0-alpha03, and androidx.sqlite:sqlite-ktx:2.3.0-alpha03 are released. Version 2.3.0-alpha03 contains these commits.

API Changes

  • Make androidx.sqlite.ProcessLock restricted. The API is scoped and limited to its function within androidx.sqlite and should not be used as a general purpose multi-process lock. (I1643f)

Version 2.3.0-alpha02

April 6, 2022

androidx.sqlite:sqlite:2.3.0-alpha02, androidx.sqlite:sqlite-framework:2.3.0-alpha02, and androidx.sqlite:sqlite-ktx:2.3.0-alpha02 are released. Version 2.3.0-alpha02 contains these commits.

  • No significant changes since 2.3.0-alpha01

Version 2.3.0-alpha01

February 23, 2022

androidx.sqlite:sqlite:2.3.0-alpha01, androidx.sqlite:sqlite-framework:2.3.0-alpha01, and androidx.sqlite:sqlite-ktx:2.3.0-alpha01 are released. Version 2.3.0-alpha01 contains these commits.

API Changes

  • Add an API in SupportSQLite's configuration to allow data loss during the recovery mechanism. (I1b830, b/215592732)
  • Added API for multi-process lock and usage at the FrameworkSQLite* level, to protect multi-process 1st time database creation and migrations. (Ied267, b/193182592)

Version 2.2.0

Version 2.2.0

December 15, 2021

androidx.sqlite:sqlite:2.2.0, androidx.sqlite:sqlite-framework:2.2.0, and androidx.sqlite:sqlite-ktx:2.2.0 are released. Version 2.2.0 contains these commits.

Important changes since 2.1.0

Add default method for execPerConnectionSQL() in SupportSQLiteDatabase.

Version 2.2.0-rc01

December 1, 2021

androidx.sqlite:sqlite:2.2.0-rc01, androidx.sqlite:sqlite-framework:2.2.0-rc01, and androidx.sqlite:sqlite-ktx:2.2.0-rc01 are released. Version 2.2.0-rc01 contains these commits.

No significant changes since 2.2.0-beta01.

Version 2.2.0-beta01

October 13, 2021

androidx.sqlite:sqlite:2.2.0-beta01, androidx.sqlite:sqlite-framework:2.2.0-beta01, and androidx.sqlite:sqlite-ktx:2.2.0-beta01 are released. Version 2.2.0-beta01 contains these commits.

  • No changes from previous alpha version.

Version 2.2.0-alpha02

July 21, 2021

androidx.sqlite:sqlite:2.2.0-alpha02, androidx.sqlite:sqlite-framework:2.2.0-alpha02, and androidx.sqlite:sqlite-ktx:2.2.0-alpha02 are released. Version 2.2.0-alpha02 contains these commits.

No significant changes since 2.2.0-alpha01. This release is just to align with Room 2.4.0-alpha04 release.

Version 2.2.0-alpha01

June 16, 2021

androidx.sqlite:sqlite:2.2.0-alpha01, androidx.sqlite:sqlite-framework:2.2.0-alpha01, and androidx.sqlite:sqlite-ktx:2.2.0-alpha01 are released. Version 2.2.0-alpha01 contains these commits.

API Changes

  • Add default method for execPerConnectionSQL() in SupportSQLiteDatabase (I86326, b/172270145)

Version 2.1.0

Version 2.1.0

January 22, 2020

androidx.sqlite:sqlite:2.1.0, androidx.sqlite:sqlite-framework:2.1.0, and androidx.sqlite:sqlite-ktx:2.1.0 are released with no changes since 2.1.0-rc01. Version 2.1.0 contains these commits.

Important changes since 2.0.1

  • Support for useNoBackupDirectory which can be used to indicate that the database should be created in the no backup directory when using SupportSQLiteOpenHelper.

Version 2.1.0-rc01

January 8, 2020

androidx.sqlite:sqlite-*:2.1.0-rc01 is released. Version 2.1.0-rc01 contains these commits.

This release is identical to 2.1.0-beta01.

Version 2.1.0-beta01

December 4, 2019

androidx.sqlite:sqlite:2.1.0-beta01, androidx.sqlite:sqlite-framework:2.1.0-beta01, and androidx.sqlite:sqlite-ktx:2.1.0-beta01 are released with no changes since 2.1.0-alpha01. Version 2.1.0-beta01 contains these commits.

Version 2.1.0-alpha01

November 7, 2019

androidx.sqlite:sqlite:2.1.0-alpha01, androidx.sqlite:sqlite-framework:2.1.0-alpha01, and androidx.sqlite:sqlite-ktx:2.1.0-alpha01 are released. Version 2.1.0-alpha01 contains these commits.

API changes

  • Added a new property to SupportSQLiteOpenHelper.Configuration called useNoBackupDirectory to indicate that a file based database should be created and located from the no backup directory.

Version 2.0.1

Version 2.0.1

March 13, 2019

Version 2.0.1 of the androidx.sqlite artifact group is released with two bug fixes.

Bug Fixes

  • Fixed two issues where FrameworkSQLiteOpenHelper wouldn’t properly recover from a corrupted database or a bad migration during initialization. (b/111504749 and b/111519144)