Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
Android 9 introduces a special mode of
SQLiteDatabase
called Compatibility write-ahead logging (WAL) that allows a database to use
journal_mode=WAL while preserving the behavior of keeping a maximum of one
connection per database.
Compatibility WAL is enabled for an app's database by default unless the
app has either:
Explicitly requested journal mode by calling
SQLiteDatabase.OpenParams.setJournalMode(String mode)
Enabling the WAL journal mode can lead to a significant improvement in
performance and reduction in the amount of writes. For example, on an ext4
file system, WAL can lead to a 4x improvement in write speed.
Compatibility WAL is enabled by default and doesn't require any additional
implementation.
You may want to disable Compatibility WAL for configurations where the WAL
journal mode doesn't provide a performance advantage over traditional rollback
journal modes. For example, on a F2FS file system, although SQLite supports
atomic writes and the DELETE journal performance is similar to WAL, WAL can
increase the amount of writes by 10% to 15%.
Validation
To validate the Compatibility WAL mode, run
CTS tests
from the CtsDatabaseTestCases module. CTS tests will verify the expected
behavior when Compatibility WAL is enabled.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-06-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-18 UTC."],[],[],null,["# Compatibility write-ahead logging for apps\n\nAndroid 9 introduces a special mode of\n[SQLiteDatabase](https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html)\ncalled Compatibility write-ahead logging (WAL) that allows a database to use\n`journal_mode=WAL` while preserving the behavior of keeping a maximum of one\nconnection per database.\n\nCompatibility WAL is enabled for an app's database by default unless the\napp has either:\n\n1. Opted-in or out of write-ahead logging by calling [`SQLiteDatabase.enableWriteAheadLogging`](https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#enableWriteAheadLogging()) or [`disableWriteAheadLogging`](https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#disableWriteAheadLogging())\n2. Explicitly requested journal mode by calling `SQLiteDatabase.OpenParams.setJournalMode(String mode)`\n\nEnabling the WAL journal mode can lead to a significant improvement in\nperformance and reduction in the amount of writes. For example, on an ext4\nfile system, WAL can lead to a 4x improvement in write speed.\n\nCompatibility WAL is enabled by default and doesn't require any additional\nimplementation.\n| **Note:** For apps using [Room](https://developer.android.com/topic/libraries/architecture/room), full write-ahead logging mode (not Compatibility WAL) is enabled by default. This applies to devices running API 16 and higher and aren't categorized as a [low memory device](https://developer.android.com/reference/android/app/ActivityManager.html#isLowRamDevice()). For more information, see [`RoomDatabase.JournalMode AUTOMATIC`](https://developer.android.com/reference/androidx/room/RoomDatabase.JournalMode#AUTOMATIC).\n\nDisable Compatibility WAL\n-------------------------\n\nTo disable the Compatibility WAL mode, overlay the\n[`db_compatibility_wal_supported`](https://android.googlesource.com/platform/frameworks/base/+/5bd43ad2e7e4e1ee2c31d920ba4b148bbdf74d11/core/res/res/values/config.xml#1692)\nconfig resource.\n\nFor example: \n\n \u003cbool name=\"db_compatibility_wal_supported\"\u003efalse\u003c/bool\u003e\n\nYou may want to disable Compatibility WAL for configurations where the WAL\njournal mode doesn't provide a performance advantage over traditional rollback\njournal modes. For example, on a F2FS file system, although SQLite supports\natomic writes and the DELETE journal performance is similar to WAL, WAL can\nincrease the amount of writes by 10% to 15%.\n\nValidation\n----------\n\nTo validate the Compatibility WAL mode, run\n[CTS tests](https://android.googlesource.com/platform/cts/+/android16-release/tests/tests/database)\nfrom the CtsDatabaseTestCases module. CTS tests will verify the expected\nbehavior when Compatibility WAL is enabled.\n| **Note:** CTS tests pass when the Compatibility WAL mode is disabled."]]