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 18, 2023 2.4.0 - - -

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.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)