I am working with a SQLITE database from within my app. The database file itself is stored as "data.db" in the documents folder.
Since users should be able to backup and restore this data I need to make a copy of the database file.
How could this be done at best (creating a copy of the database file in the documents directory)?
Currently I am trying to use io.open / io.write to read in the database file in binary mode and writing it to a destination file ("backup.db") - but the Simulator does not allow this and gives a "permission denied" warning as soon as I try to io.open the database file for binary reading.
Of course I close the database connection before using the DB:close() method, but this does no make a difference. I also used a time delay between closing the database and copying the file but this also gives a "permission denied".
It seems that the database file is locked as soon as it is accessed the first time from within the app and not released anymore until the app is completely terminated again (f.e. Simulator closed)
Does SQLITE offer any built-in methods to clone a database file?
Or are there any other ways to do so?