Sqlite
androidx.sqlite
程式庫包含抽象介面和基本實作,可用來建構您的資料庫來存取 SQLite。
建議您考慮使用 Room 程式庫,原因在於該程式庫透過 SQLite 提供抽象層,讓您存取更多完善的資料庫,並同時充分利用 SQLite 的強大功能。
最近更新時間 | 穩定版 | 候選版 | Beta 版 | Alpha 版 |
---|---|---|---|---|
2022 年 6 月 1 日 | 2.2.0 | - | - | 2.3.0-alpha03 |
宣告依附元件
如要新增 SQLite 的依附元件,您必須在專案中新增 Google Maven 存放區。詳情請參閱 Google 的 Maven 存放區。
在應用程式或模組的 build.gradle
檔案中,新增您需要的構件依附元件:
Groovy
dependencies { def sqlite_version = "2.2.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.2.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") }
如要進一步瞭解依附元件,請參閱「新增建構依附元件」一文。
意見回饋
您的意見可協助我們改善 Jetpack。發現新的問題或有改善這個程式庫的想法時,請告訴我們。建立新的問題之前,請先查看這個程式庫中的 現有問題。只要按一下星號按鈕,即可投票給現有的問題。
詳情請參閱 Issue Tracker 說明文件。
2.3.0 版本
2.3.0-alpha03 版本
2022 年 6 月 1 日
釋出 androidx.sqlite:sqlite:2.3.0-alpha03
、androidx.sqlite:sqlite-framework:2.3.0-alpha03
和 androidx.sqlite:sqlite-ktx:2.3.0-alpha03
。2.3.0-alpha03 版本包含這些修訂版本。
API 異動
- 將
androidx.sqlite.ProcessLock
設為受限。API 作用範圍已設定並限制為在androidx.sqlite
內的功能,不應用作一般用途的多行程鎖定。(I1643f)
2.3.0-alpha02 版
2022 年 4 月 6 日
釋出 androidx.sqlite:sqlite:2.3.0-alpha02
、androidx.sqlite:sqlite-framework:2.3.0-alpha02
和 androidx.sqlite:sqlite-ktx:2.3.0-alpha02
。瞭解 2.3.0-alpha02 版包含哪些修訂版本。
- 自 2.3.0-alpha01 版以來皆無重大異動
2.3.0-alpha01 版
2022 年 2 月 23 日
釋出 androidx.sqlite:sqlite:2.3.0-alpha01
、androidx.sqlite:sqlite-framework:2.3.0-alpha01
和 androidx.sqlite:sqlite-ktx:2.3.0-alpha01
。2.3.0-alpha01 版本包含這些修訂版本。
API 異動
- 在 SupportSQLite 的設定中新增 API,允許在復原機制過程的資料遺失。(I1b830, b/215592732)
- 在 FrameworkSQLite* 層級新增用於鎖定及使用多程序的 API,以保護首次建立及遷移資料庫的多程序工作。(Ied267、b/193182592)。
2.2.0 版本
2.2.0 版本
2021 年 12 月 15 日
已釋出 androidx.sqlite:sqlite:2.2.0
、androidx.sqlite:sqlite-framework:2.2.0
和 androidx.sqlite:sqlite-ktx:2.2.0
。2.2.0 版包含這些修訂版本。
自 2.1.0 版以來的重要異動
新增 SupportSQLiteDatabase
中 execPerConnectionSQL()
的預設方法。
2.2.0-rc01 版本
2021 年 12 月 1 日
釋出 androidx.sqlite:sqlite:2.2.0-rc01
、androidx.sqlite:sqlite-framework:2.2.0-rc01
和 androidx.sqlite:sqlite-ktx:2.2.0-rc01
。版本 2.2.0-rc01 包含這些修訂版本。
自 2.2.0-beta01 起沒有重大異動。
2.2.0-beta01 版本
2021 年 10 月 13 日
釋出 androidx.sqlite:sqlite:2.2.0-beta01
、androidx.sqlite:sqlite-framework:2.2.0-beta01
和 androidx.sqlite:sqlite-ktx:2.2.0-beta01
。 2.2.0-beta01 版本包含這些修訂版本。
- 自前一個 Alpha 版起沒有任何異動。
2.2.0-alpha02 版本
2021 年 7 月 21 日
釋出 androidx.sqlite:sqlite:2.2.0-alpha02
、androidx.sqlite:sqlite-framework:2.2.0-alpha02
和 androidx.sqlite:sqlite-ktx:2.2.0-alpha02
。2.2.0-alpha02 版本包含這些修訂版本。
自 2.2.0-alpha01 起沒有重大異動。此版本只是與 2.4.0-alpha04
會議室 搭配使用的版本。
2.2.0-alpha01 版本
2021 年 6 月 16 日
釋出 androidx.sqlite:sqlite:2.2.0-alpha01
、androidx.sqlite:sqlite-framework:2.2.0-alpha01
和 androidx.sqlite:sqlite-ktx:2.2.0-alpha01
。2.2.0-alpha01 版本包含這些修訂版本。
API 異動
- 在 SupportSQLiteDatabase 中新增
execPerConnectionSQL()
的預設方法 (I86326、b/172270145)
2.1.0 版本
2.1.0 版本
2020 年 1 月 22 日
androidx.sqlite:sqlite:2.1.0
、androidx.sqlite:sqlite-framework:2.1.0
和 androidx.sqlite:sqlite-ktx:2.1.0
自 2.1.0-rc01
起未發布任何異動。2.1.0 版本包含這些修訂版本。
自 2.0.1 版本起的重要異動
- 支援
useNoBackupDirectory
,表示使用SupportSQLiteOpenHelper
時,資料庫必須建立在無備份目錄。
2.1.0-rc01 版本
2020 年 1 月 8 日
已釋出 androidx.sqlite:sqlite-*:2.1.0-rc01
。2.1.0-rc01 版包含這些修訂版本。
這個版本與 2.1.0-beta01
相同。
2.1.0-beta01 版本
2019 年 12 月 4 日
androidx.sqlite:sqlite:2.1.0-beta01
、androidx.sqlite:sqlite-framework:2.1.0-beta01
和 androidx.sqlite:sqlite-ktx:2.1.0-beta01
自 2.1.0-alpha01
起未發布任何異動。2.1.0-beta01 版本包含這些修訂版本。
2.1.0-alpha01 版本
2019 年 11 月 7 日
釋出 androidx.sqlite:sqlite:2.1.0-alpha01
、androidx.sqlite:sqlite-framework:2.1.0-alpha01
和 androidx.sqlite:sqlite-ktx:2.1.0-alpha01
。2.1.0-alpha01 版本包含這些修訂版本。
API 異動
- 已將新屬性新增至
SupportSQLiteOpenHelper.Configuration
並命名為useNoBackupDirectory
,表示必須建立位於檔案備份資料庫,而不是位於備份目錄。
2.0.1 版本
2.0.1 版本
2019 年 3 月 13 日
「androidx.sqlite
」構件群組的 2.0.1 版已發布兩個錯誤修正。
修正錯誤
- 已修正兩點問題,即
FrameworkSQLiteOpenHelper
無法正確從損毀資料庫復原、以及在初始化期間出現錯誤遷移。(b/111504749 及 b/111519144)