I want to know why SQLite create two file inside the path.and what is the diffrence these files.
I have a database name mydatabase.
when i see in given path there are two files.
data/data/pack name/databases/....
1- mydatabase
2- mydatabase-journal
mydatabaseis main database file, which contains everything about that database.mydatabase-journalis journal file. It does not exist by default, and only gets created by SQLite when necessary to keep intent log of what SQLite wants to do with database. Basically, this is intent of what should be done to main database file after transaction is properly finished. If you finish all transactions normally and disconnect from database gracefully,-journalfile will be normally removed automatically.If disconnect was abrupt – like process killed or crashed,
-journalfile will remain and should NOT be deleted. When next time SQLite opens this database once again, it will notice presence of-journalfile and will replay or rollback unfinished transactions, such that main database file is consistent and not corrupted.If you remove
-journalfile manually, recovery is not guaranteed and database may be completely corrupted – so, DO NOT remove-journalfiles.Probably easiest way to properly get rid of
-journalfiles is to do this command:It will VACUUM (optimize) your database and should leave only main file as a result.