How to move a database file to the sandbox?

Hello

my game has a database of hundreds of questions and answers,

this is the structure of the questions table


question = String

answer = String

solved = Boolean


once the player solve a question the game should change the value of “solved” column to “true”

I was able to achieve this in the simulator, but not in the device! I have spent more than 3 hours trying to know why it is not working in the device!!!, at the end I figured out that I was placing my database into the resource folder which is not writeable so when I change the value of “solved” column to true it was not changing or even giving me an error!!! :angry:

my question is

I want to copy my database to the sandbox or any permanent writeable folder so i can save player’s progress?

Thanks in advance :slight_smile:

I ran into a similar issues.

There is an example on how to copy files here.

http://docs.coronalabs.com/api/type/File/write.html

When my app starts I check to see if the .db file exists and if not I copy over the default database from the resource directory.  The down side is there is two database files.  The bonus is it is easy to restore to the starting state easy if the database is corrupted.

Before I found that copy file routine I was creating the database in the documents directory by a large SQL insert command.  The first time my app started there was a huge delay while the database was created.  The copy routine is way better.

I ran into a similar issues.

There is an example on how to copy files here.

http://docs.coronalabs.com/api/type/File/write.html

When my app starts I check to see if the .db file exists and if not I copy over the default database from the resource directory.  The down side is there is two database files.  The bonus is it is easy to restore to the starting state easy if the database is corrupted.

Before I found that copy file routine I was creating the database in the documents directory by a large SQL insert command.  The first time my app started there was a huge delay while the database was created.  The copy routine is way better.

That works! Thank you very much.

That works! Thank you very much.