During the process of generating SQLite database files on the SD card in Android today, we found that
A. DB-Journal file with the same name as the database file with a size of 0 is generated. I do not understand the purpose of this file, so
Google's SQLite official documentation found that the file is used as follows:
This file is a temporary log file of SQLite. It is mainly used for the SQLite transaction rollback mechanism and is generated at the beginning of the transaction,
Delete at the end of the transaction;WhenProgramThe file will remain on the disk in case of a crash or system power failure, so that the next program will run
Transaction rollback.
However, when I create a database, the transaction ends and the program does not crash. Why is it still generated on the disk?
What about the. DB-Journal File?
In-depth research found that this is caused by different log file generation modes of SQLite. In Android,
. DB-Journal FileIt is permanently left on the disk and will not be automatically cleared. If no transaction rollback occurs, then. DB-Journal
The file size is 0, which avoidsOverhead of generating and deleting a. DB-Journal File each time.
At this point, all the doubts have been solved.