To check my database I always open Device File Explorer and navigate to package.name> databases> here I find 3 files: dbName, dbName-shm, dbName-wal. The file that I occupy is dbName, so I right click and choose "Save as ..." after choosing the path the file is saved, later I check it with a software called "DB Browser for SQLite".
I had never had problems to see my database, but about 1 week ago the problems started, because the file called "dbName" is never updated, how do I know that? In the column "Date" the last modification date of each file, dbName.shm and dbName-wal change value in "Date" when I tap on "Synchronize" but "dbName" keeps the creation date and time, when opening the file with "DB Browser" there is nothing.
What is the problem? Has the path where my database is being saved changed?
CodePudding user response:
The symptoms you are describing are consistent with the -wal (i.e. dbName-wal) doing what it is designed to do.
The short fix is to save all three files NOT just the dbName file.
The better/safer fix is to close the database, ensuring that the database is fully committed.
The -wal file, if it exists and is not empty is part of the database. Opening just the dbName file without the -wal file will mean that some of the database is missing.
The -wal file is used for logging changes for use when a roll-back is required or requested. As such changes are first applied to the -wal file which SQLite knows to be part of the database. I the event that a rollback being required the relevant pages in the -wal file can be removed.
The changes held in the -wal file are applied to the actual database file by COMMITS some of which are actioned, by default, automatically. The automatic COMMITS may not COMMIT all changes. However, closing the database will COMMIT all changes.
You may wish to see https://sqlite.org/wal.html