[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 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."]]