Search code examples
android-studioandroid-sqliteandroid-9.0-pie

Database tables are not visible in Android Pie 9


I have tested my app (with an sqlite databse) on a Android 9.0 Pie phone, when I opened the data base in DB sqlite browser, it was not showing the tables that I created in my Sqlite databse. I did the same on emulator of Android 9.0 Pie within Android Studio... but database tables are not visible


Solution

  • Your issue is probably that you have only copied the database file and not the -wal and -shm files. Try copying all three files and the tables will then probably be available.

    • The -wal and -shm files have the same name as the database file but suffixed with -wal and -shm respectively.

    The reason is that with Android Pie on, the default mode is WAL (write-ahead logging) as opposed to journal mode that was the previous default mode.

    With journal mode changes are written to the database and also stored in the journal file allowing changes to be rolled back from the journal file.

    With WAL mode the changes are written to the -wal file (which is effectively part of the database), a rollback effectively deletes the changes from the -wal file. However, if the -wal file has not been commited to the actual database and the database is opened without the -wal file then the changes will appear to have been lost.

    If the database is fully closed this will checkpoint and include the changes in the -wal file to the database file.