Search code examples
androidsqliteandroid-versionandroid-9.0-pie

Changes on Android 9 Pie creating SQLite database files on phone (?)


Im creating an app but when i start to create the database clases (sqlite) and it works , now the sqlite files are different in android 9, in anothers versions you go to /data/data/packageapp/databases and you found database.sqlite and database.sqlite-journal, now i found this and this files cant open on sqlite administrator or similars... But the databases works i dont know what happen, i want to create the last files

Check the photo

https://i.sstatic.net/zV8hB.jpg


Solution

  • With Android 9 SQLite by default it now uses Write-Ahead Logging mode (WAL) instead of the journal mode due to it's potential for increased performance. Which is why you see the the -shm (Shared Memory file) and the -wal (Write Ahead Logging file) files.

    Temporary Files Used By SQLite

    However, you should be able to open the actual database file (yonuncafrases.sqlite) elsewhere in tools that support opening SQLite Databases. Compatibility WAL (Write-Ahead Logging) for Apps

    i want to create the last files

    If need be you can force using journal mode by using the SQLite disableWriteAheadLogging method, noting that this must be done outside a transaction, and then Journal Mode would be used and that the -journal file would then be created as necessary.

    • I'd suggest overwriting the onConfigure method and calling disableWriteAheadLogging in that overridden method. Alternatively you could use the journal_mode pragma (which I believe is what disableWriteAheadLogging does anyway)

    You may wish to read Write-Ahead Logging