Insert a SQL-DB file

Hi guys,

I am trying to insert a sql.db file into the app.

This is a pre-populated db file with data inside (size ~100kB)

This is my code :

local path = system.pathForFile( "/asset/misc/sql.db" ) local db = sqlite3.open( path )

This code works fine in the simulator, but when I built and test it on an Android device, this error appears (in other words, the ‘path’ is not found )

attempt to index up value 'db' (a nil value)

A quick check on whether the sql.db file exist returned ‘false’, meaning the Android app could not find this sql.db file

Please advise on the best way to include a pre-populated sql.db in the app

Thanks

After much troubleshooting, this is how it was solved :

Place the sql.db file in “system.ResourceDirectory”, which is the same as ‘main.lua’

Access the sql.db file :

local path = system.pathForFile( "sql.db", system.ResourceDirectory ) local db = sqlite3.open( path )

Done!

After much troubleshooting, this is how it was solved :

Place the sql.db file in “system.ResourceDirectory”, which is the same as ‘main.lua’

Access the sql.db file :

local path = system.pathForFile( "sql.db", system.ResourceDirectory ) local db = sqlite3.open( path )

Done!