sqlite3 error code 8

Hi guys!!

I am having problems with the external database I created, I have a structured bank called “speakaut.db”, when I try to insert some registry in this bank the system returns me the error code 8. how can I open the database in writing mode ?

Detail: the first time the app is installed, the database is copied from “system.ResourceDirectory” to “system.DocumentsDirectory” and I can enter the records normally, but when the app is closed and reopened the database. Data is in read-only mode.

How do I solve this problem? Follows the code tread that copies the bank to the sandbox.

local sqlite = require (“sqlite3”)

local path = system.pathForFile(“speakaut.db”, system.DocumentsDirectory)

print (path)

file = io.open( path, “r” ) 

 if( file == nil )then 

 --Database doesn’t already exist, so copy it from the 

 --resource directory 

 pathSource = system.pathForFile( “speakaut.db”, system.ResourceDirectory ) 

 print ("PATH SOURCE >> " … pathSource)

 fileSource = io.open( pathSource, “rb” ) 

 contentsSource = fileSource:read( “*a” ) 

 --Write Destination File in Documents Directory 

 pathDest = system.pathForFile( “speakaut.db”, system.DocumentsDirectory ) 

 fileDest = io.open( pathDest, “wb” ) 

 fileDest:write( contentsSource )  

 – Done 

 io.close( fileSource ) 

 io.close( fileDest ) 

 end 

db = sqlite3.open( path )

  

You might want to try and close “file” before you open the database. I don’t know if that’s causing a lock or not.

Rob

exactly!
After closing the file, I can open the database in writing mode. thank you

You might want to try and close “file” before you open the database. I don’t know if that’s causing a lock or not.

Rob

exactly!
After closing the file, I can open the database in writing mode. thank you