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. When the program crashes or the system is powered off, the file will remain on the disk for the next program to 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 files are permanently stored on the disk and will not be automatically cleared. If no transaction rollback occurs, then. DB-Journal
The file size is 0, which avoids the overhead of every generation and deletion of the. DB-Journal File.
At this point, all the doubts have been solved.
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. When the program crashes or the system is powered off, the file will remain on the disk for the next program to 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 files are permanently stored on the disk and will not be automatically cleared. If no transaction rollback occurs, then. DB-Journal
The file size is 0, which avoids the overhead of every generation and deletion of the. DB-Journal File.
At this point, all the doubts have been solved.