I’m currently developing a BackupHelper for the databases of my Android apps. The method Context.databaseList() reports the names of all databases that do belong to my app. But I do experience a lot of additional files beside the main SQLite database files (e.g.):
- database.db
- database.db-journal
- database.db-shm
- database.db-wal
All Android docs tell about a single database file per database but this information seems to be outdated.
Is it save to store all those files with the BackupHelper?
Will SQLite work with these files on all Android platforms after a restore?
Many thanks in advance.
Did some Googling and found some info about the other files:
SQLite by default creates the journal file at the start of a transaction, which is a good thing. Normally it deletes the file upon commit.
You can change this behavior to simply truncate the file (no create/delete necessary) or to zero it, via a PRAGMA sql command. Not all options may be supported on your version of SQLite.
Write operations are normally not completed until you COMMIT, which is implemented by truncating, deleting, or invalidating the journal.
If this behavior is new, I have no explanation for why it might have changed, other than perhaps an upgrade of SQLite changed default behavior, or has become more sophisticated by not reopening the journal for every transaction.
Source
These are temporary files created by SQLite. If you are manually deleting the main db you should probably delete these too. From what I can gather the WAL is a replacement for the rollback journal that enables SQLite to rollback changes when a transaction fails. How SQLite uses them and why they are kept around for so long is up to the authors of SQLite but in general SQLite seems pretty rock solid so I wouldn’t worry too much about them. For more info take a look here:
http://www.sqlite.org/fileformat2.html#walindexformat
These files are a new feature of SQLite 3.7.
Source
Hope that helps…