1

I'm debugging an issue with an Android application that seems to stem from missing data in its SQLite database. When I open the database using Android Debug Database, the data is shown. However, when I save the SQLite file to my computer using Android Studio's Device File Explorer and then open it up with a SQLite client, the data is missing.

Using Room to manage the SQLite db, and used both TablePlus and DB Browser for SQLite to view the db on my computer.

6
  • "when I save the SQLite file to my computer using Android Studio's Device File Explorer" -- there may be three files, not just one.CommentedJul 6, 2019 at 13:56
  • Yes, there are - there's the 'normal' file plus a wal and shm file. The wal file is empty and the shm file can't be read by DB Browser for SQLite (may be encrypted?). How do these files relate to the discrepancy?
    – user1114
    CommentedJul 6, 2019 at 14:08
  • Are you copying all three? Room has WAL (write-ahead logging) enabled, so you need all three to represent the contents of the database.CommentedJul 6, 2019 at 14:10
  • That solved it! When copying all three, the data appears!
    – user1114
    CommentedJul 6, 2019 at 14:12
  • Could the data being in the other two files cause the application to think the db doesn't contain it? In the same vein, is there a configuration to set to ask the application to consider the other two files as well when querying, or is all of that taken care of behind the scenes by Room?
    – user1114
    CommentedJul 6, 2019 at 14:14

1 Answer 1

1

Room uses write-ahead logging (WAL). Much of the time, this means that the SQLite database consists of three files:

  • Whatever you named the base file
  • One with .wal
  • One with .shm

You need to copy all three if you wish to use the database elsewhere (e.g., desktop SQLite browser, backup/restore).

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.