Kindle Fire HD and SQLite problem

Hi,

I’m currently having problems with SQLite and the Kindle Fire HD.

I’m trying to get my finished game running (which runs fine on iOS) on the Kindle.

I open the database like this:

function openDB()  
 print("OpenDB")  
 local path = system.pathForFile("game1.db", system.DocumentsDirectory)  
 db = sqlite3.open( path )  
end  

I pinpointed the problem when i try to update a record in the database like this:

function UnlockArea(ItemName)  
 if db and db:isopen() then  
 print("DB is open")  
 else  
 print("DB is closed")  
 end  
 print ("Unlock area: "..ItemName)  
 local sql =[[UPDATE Doors SET Locked = 0 WHERE ItemName = (']]..ItemName..[[');]]  
 db:exec( sql )  
 print("sql: "..sql)  
 print("db result: "..db:errcode())  

So i’m trying to set Locked to 1 in the Doors table, where ItemName = xxx
Works perfectly on iOS, simulator, etc. On the Kindle Fire, it gives an error 14:
SQLITE_CANTOPEN 14 /* Unable to open the database file */

Sometimes, when i try to update other elements in the database, i get:
SQLITE_ERROR 1 /* SQL error or missing database */

The database IS open, thats not the problem. The SQL string is valid, too.

I am able to write to the database in an earlier stage of the game, too.

Strange thing is, when I exit to the main menu of the game, and return to the game, it works flawlessly.

Do I need to open and close the db everytime I write to it?

Anybody any idea how to solve this problem? [import]uid: 50459 topic_id: 31388 reply_id: 331388[/import]

Sounds like something is closing the database. You could try explicitly opening it before each read or write and see of the problem goes away – then at least you’d have a better idea of what to look for.

I haven’t seen that on the Kindle Fire, but I don’t have the HD version.

Jay [import]uid: 9440 topic_id: 31388 reply_id: 125494[/import]

Any luck on this I would like to know how it went.

Larry Meadows
DoubleSlashDesign.com [import]uid: 11860 topic_id: 31388 reply_id: 125505[/import]

I don’t close the database anywhere, and check if DB = open before I try to write to it.

According to:

if db and db:isopen() then

The database is open but still get the #14 error.

I created a workaround by closing and reopening the database everytime i write to it:

Not pretty, but it works.
[import]uid: 50459 topic_id: 31388 reply_id: 125568[/import]

Sounds like something is closing the database. You could try explicitly opening it before each read or write and see of the problem goes away – then at least you’d have a better idea of what to look for.

I haven’t seen that on the Kindle Fire, but I don’t have the HD version.

Jay [import]uid: 9440 topic_id: 31388 reply_id: 125494[/import]

Any luck on this I would like to know how it went.

Larry Meadows
DoubleSlashDesign.com [import]uid: 11860 topic_id: 31388 reply_id: 125505[/import]

I don’t close the database anywhere, and check if DB = open before I try to write to it.

According to:

if db and db:isopen() then

The database is open but still get the #14 error.

I created a workaround by closing and reopening the database everytime i write to it:

Not pretty, but it works.
[import]uid: 50459 topic_id: 31388 reply_id: 125568[/import]