Project: /_project.yaml Book: /_book.yaml
{% include “_versions.html” %}
Android {{ androidPVersionNumber }} introduces a special mode of SQLiteDatabase{: .external} called Compatibility WAL (write-ahead logging) 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 application's database by default unless the application has either:
SQLiteDatabase.enableWriteAheadLogging
{: .external} or disableWriteAheadLogging
{: .external}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 filesystem, WAL can lead to a 4x improvement in write speed.
Compatibility WAL is enabled by default and doesn't require any additional implementation.
Note: For applications using Room, full write-ahead logging mode (not Compatibility WAL) is enabled by default. This applies to devices running API 16 and higher and are not categorized as a low memory device. For more information, see RoomDatabase.JournalMode AUTOMATIC
.
To disable the Compatibility WAL mode, overlay the db_compatibility_wal_supported
{: .external} config resource.
For example:
<bool name="db_compatibility_wal_supported">false</bool>
You may want to disable Compatibility WAL for configurations where the WAL journal mode does not provide a performance advantage over traditional rollback journal modes. For example, on a F2FS filesystem, 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%.
To validate the Compatibility WAL mode, run CTS tests{: .external} from the CtsDatabaseTestCases module. CTS tests will verify the expected behavior when Compatibility WAL is enabled.
Note: CTS tests pass when the Compatibility WAL mode is disabled.