Mulai 27 Maret 2025, sebaiknya gunakan android-latest-release, bukan aosp-main, untuk mem-build dan berkontribusi pada AOSP. Untuk mengetahui informasi selengkapnya, lihat Perubahan pada AOSP.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Android 9 memperkenalkan mode khusus
SQLiteDatabase
yang disebut Logging write-ahead kompatibilitas (WAL) yang memungkinkan database menggunakan
journal_mode=WAL sekaligus mempertahankan perilaku untuk mempertahankan maksimum satu
koneksi per database.
WAL kompatibilitas diaktifkan untuk database aplikasi secara default, kecuali jika
aplikasi memiliki:
Meminta mode jurnal secara eksplisit dengan memanggil
SQLiteDatabase.OpenParams.setJournalMode(String mode)
Mengaktifkan mode jurnal WAL dapat menyebabkan peningkatan performa yang signifikan dan pengurangan jumlah penulisan. Misalnya, pada sistem file ext4, WAL dapat menghasilkan peningkatan kecepatan tulis 4x lipat.
WAL kompatibilitas diaktifkan secara default dan tidak memerlukan penerapan tambahan.
Anda dapat menonaktifkan WAL Kompatibilitas untuk konfigurasi saat mode jurnal WAL
tidak memberikan keunggulan performa dibandingkan mode jurnal rollback
tradisional. Misalnya, pada sistem file F2FS, meskipun SQLite mendukung
penulisan atomik dan performa jurnal DELETE mirip dengan WAL, WAL dapat
meningkatkan jumlah penulisan sebesar 10% hingga 15%.
Validasi
Untuk memvalidasi mode WAL Kompatibilitas, jalankan
pengujian CTS
dari modul CtsDatabaseTestCases. Pengujian CTS akan memverifikasi perilaku
yang diharapkan saat WAL Kompatibilitas diaktifkan.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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."]]