embed read only database

Thanks 'yall

I see what I was missing now.

I’ve been using 

local path = system.pathForFile(“GameSetup.sqlite”, system.DocumentsDirectory )

instead of 

local path = system.pathForFile(“GameSetup.sqlite”, system.ResourceDirectory)

Thanks

It sort of sounds like you’re able to generate the database dynamically, but I’m not sure.

If so, you could create it on the first run in the simulator , where you have some leeway with the resource directory. As long as it’s there, it would then get picked up during builds.

If you want your mobile app to create the database, you will still need to use system.DocumentsDirectory, but once it’s populated, move it to the folder with your main.lua and then in the future reference it from system.DocumentsDirectory.

Hi Rob,

sorry I"m having a hard time here with the concept still,

Are you saying I can move it between locations in runtime?

For your use, no, this is not what I’m talking about.   However it is a common practice to include an SQLite database in your ResourceDirectory (which is read only) and then on first start, create a writable DB in DocumentsDirectory and read all the records from the read only DB and write them to the writable DB for future use when you need a pre-populated writable DB.

But in your case, you need a way to create the read only DB.  There are various tools to do this, but if you want to use Corona, the Simulator and such to create the initial database, then you can use the simulator to build the SQLite DB and when it’s populated, copy it on your computer into the folder with main.lua and have your actual app look in system.ResourcesDirectory to find the read only DB.

Rob