Hi…I’m working on 2 os (osX and windows 7) at the same project.
I added at my project a db made by sqlite3 and on OsX the project runs. But when i work on windows the project show me an error during creation of database.
Error : Attempt to index local fileSource (a nil value)
Why that? What change between 2 os?
I allegate the code:
local function setUpDatabase(dbName) local path = system.pathForFile( dbName, system.DocumentsDirectory ) local file = io.open( path, "r" ) if ( file == nil ) then -- copy the database file if doesn't exist local pathSource = system.pathForFile( dbName, system.ResourceDirectory ) local fileSource = io.open( pathSource, "r" ) local contentsSource = fileSource:read( "\*a" ) local pathDest = system.pathForFile( dbName, system.DocumentsDirectory ) local fileDest = io.open( pathDest, "w" ) fileDest:write( contentsSource ) io.close( fileSource ) io.close( fileDest ) end local DB = system.pathForFile(dbName, system.DocumentsDirectory) local dbNew = sqlite3.open( DB ) return dbNew end db = setUpDatabase("data.db")