Game doesnt Update Database on Phone

Hey guys I have a Problem:
So I want to create a Quiz Game and the Game should check if I already made the Quiz if so it should update a false image to a true image.
Here:

 local rimage = display.newImage(localGroup, "images/rightPreview.png")  
 rimage.x, rimage.y = 50, 90;  
 rimage.alpha = 0  
  
 local wimage = display.newImage(localGroup, "images/wrongPreview.png")  
 wimage.x, wimage.y = 50, 90;  
 wimage.alpha = 1  
  
 function checkQuizes()  
 for l = 1, 1, 1 do  
 if l == i then  
 if sqls.getInformation("name", 1, "l" .. i) == 1 then  
 rimage.alpha = 1  
 wimage.alpha = 0  
 end  
 end  
 end  
 end  
  
 checkQuizes();  

And the Database get updated when you finished the Quiz here:

 function updateSQL(e)  
 for i = 1, 10, 1 do  
 if i == e then  
 sqls.updateRowInTable(1, "name", 1, "l" .. e, 1)  
 else  
 sqls.updateRowInTable(1, "name", 1, "l" .. i, sqls.getInformation("name", 1, "l" .. i) )  
 end  
 end  
 end  
  
 function goButton:touch(e)  
 if e.phase == "ended" then  
 if defaultField.text == nil then  
 wimage.alpha = 1;  
 rimage.alpha = 0;  
 else  
 if defaultField.text == correctText then  
 updateSQL(1)  
 wimage.alpha = 0;  
 rimage.alpha = 1;  
 else  
 wimage.alpha = 1;  
 rimage.alpha = 0;  
 end  
 end   
 end  
 end  

SQL:

function updateRowInTable(id, databasename, speicherplatz, l, varL)  
local path = system.pathForFile( databasename .. ".db", system.DocumentsDirectory )  
local db = sqlite3.open( path )  
  
local tablesetup = [[CREATE TABLE IF NOT EXISTS levels (id INTEGER PRIMARY KEY, l1 INTEGER, l2 INTEGER, l3 INTEGER, l4 INTEGER, l5 INTEGER, l6 INTEGER, l7 INTEGER, l8 INTEGER, l9 INTEGER, l10 INTEGER);]]  
db:exec( tablesetup )  
local q = [[UPDATE levels SET ']] .. l .. [[' =']] .. varL .. [[' WHERE id=']] .. speicherplatz ..[[';]]  
db:exec( q )  
end  

and

function getInformation(databasename, speicherplatz, informationsname)  
local path = system.pathForFile( databasename .. ".db", system.DocumentsDirectory )  
local db = sqlite3.open( path )  
  
for row in db:nrows("SELECT " .. informationsname .. " FROM levels WHERE id=" .. speicherplatz) do  
 for k = 1, 10, 1 do  
 if informationsname == "l" .. k then  
 if k == 1 then return row.l1  
 elseif k == 2 then return row.l2   
 elseif k == 3 then return row.l3   
 elseif k == 4 then return row.l4   
 elseif k == 5 then return row.l5   
 elseif k == 6 then return row.l6   
 elseif k == 7 then return row.l7   
 elseif k == 8 then return row.l8   
 elseif k == 9 then return row.l9   
 elseif k == 10 then return row.l10   
 end  
 end  
 end  
end  

So my Problem is on my Windows 7 Pc it worked, but when I install my Game on my Android Phone ( Sony Xperia U ) it doesnt Update the Image anymore…

Anyone who could help me? [import]uid: 145807 topic_id: 30102 reply_id: 330102[/import]

The most common reason this happens is that file names on your Windows machine are not case sensitive while on a device they are. I would check your image file names and make sure the case matches what you referenced in your code real quick. [import]uid: 147305 topic_id: 30102 reply_id: 120584[/import]

At first thanks for your Answer, but I already tested what happen on my Phone when I put the rightPreview alpha to 1 and the wrongPreview alpha to 0. And then on the Phone it shows the rightPreview. But I checked all my Image Names and they are correct / same as in the code :confused: Any other Idea? [import]uid: 145807 topic_id: 30102 reply_id: 120626[/import]

I just found the position in the code where the games crashes / gives a error:
There

function updateSQL(e)  
 for i = 1, 10, 1 do  
 if i == e then  
 sqls.updateRowInTable(1, "name", 1, "l" .. e, 1)  
 else  
 sqls.updateRowInTable(1, "name", 1, "l" .. i, sqls.getInformation("name", 1, "l" .. i) )  
 end  
 end  
 end  

or there:

function updateRowInTable(id, databasename, speicherplatz, l, varL)  
local path = system.pathForFile( databasename .. ".db", system.DocumentsDirectory )  
local db = sqlite3.open( path )  
  
local tablesetup = [[CREATE TABLE IF NOT EXISTS levels (id INTEGER PRIMARY KEY, l1 INTEGER, l2 INTEGER, l3 INTEGER, l4 INTEGER, l5 INTEGER, l6 INTEGER, l7 INTEGER, l8 INTEGER, l9 INTEGER, l10 INTEGER);]]  
db:exec( tablesetup )  
local q = [[UPDATE levels SET ']] .. l .. [[' =']] .. varL .. [[' WHERE id=']] .. speicherplatz ..[[';]]  
db:exec( q )  
end  
  
function getInformation(databasename, speicherplatz, informationsname)  
local path = system.pathForFile( databasename .. ".db", system.DocumentsDirectory )  
local db = sqlite3.open( path )  
  
for row in db:nrows("SELECT " .. informationsname .. " FROM levels WHERE id=" .. speicherplatz) do  
 if informationsname == "l1" then return row.l1  
 elseif informationsname == "l2"then return row.l2   
 elseif informationsname == "l3" then return row.l3   
 elseif informationsname == "l4" then return row.l4   
 elseif informationsname == "l5" then return row.l5   
 elseif informationsname == "l6" then return row.l6   
 elseif informationsname == "l7" then return row.l7   
 elseif informationsname == "l8" then return row.l8   
 elseif informationsname == "l9" then return row.l9   
 elseif informationsname == "l10" then return row.l10   
 end  
end  
  
end  

Could it maybe because of the updateRowInTable code ?
Please need some help :confused: [import]uid: 145807 topic_id: 30102 reply_id: 120651[/import]

Could it be that the database on your device is not up-to-date? if the levels table already exists but you have modified the table structure it will not-update what’s already on the device(at least with the code above). clearing out what’s in your sandbox on the Sim and clearing out the user data(i think) should remove the database on both systems.

Outside of that I can’t really help…I haven’t really had an issue with sqlite working on the sim but not on the device so I don’t have much else to suggest. [import]uid: 147305 topic_id: 30102 reply_id: 120656[/import]

Could you show me how? Sorry my English isnt that good to understand everything what you said . [import]uid: 145807 topic_id: 30102 reply_id: 120659[/import]

Found Problem + Solution simple as hell…
I always overrided my Game on Device but not the db now I deinstalled it and it worked… <. topic_id:="" reply_id:=""></.>

The most common reason this happens is that file names on your Windows machine are not case sensitive while on a device they are. I would check your image file names and make sure the case matches what you referenced in your code real quick. [import]uid: 147305 topic_id: 30102 reply_id: 120584[/import]

At first thanks for your Answer, but I already tested what happen on my Phone when I put the rightPreview alpha to 1 and the wrongPreview alpha to 0. And then on the Phone it shows the rightPreview. But I checked all my Image Names and they are correct / same as in the code :confused: Any other Idea? [import]uid: 145807 topic_id: 30102 reply_id: 120626[/import]

I just found the position in the code where the games crashes / gives a error:
There

function updateSQL(e)  
 for i = 1, 10, 1 do  
 if i == e then  
 sqls.updateRowInTable(1, "name", 1, "l" .. e, 1)  
 else  
 sqls.updateRowInTable(1, "name", 1, "l" .. i, sqls.getInformation("name", 1, "l" .. i) )  
 end  
 end  
 end  

or there:

function updateRowInTable(id, databasename, speicherplatz, l, varL)  
local path = system.pathForFile( databasename .. ".db", system.DocumentsDirectory )  
local db = sqlite3.open( path )  
  
local tablesetup = [[CREATE TABLE IF NOT EXISTS levels (id INTEGER PRIMARY KEY, l1 INTEGER, l2 INTEGER, l3 INTEGER, l4 INTEGER, l5 INTEGER, l6 INTEGER, l7 INTEGER, l8 INTEGER, l9 INTEGER, l10 INTEGER);]]  
db:exec( tablesetup )  
local q = [[UPDATE levels SET ']] .. l .. [[' =']] .. varL .. [[' WHERE id=']] .. speicherplatz ..[[';]]  
db:exec( q )  
end  
  
function getInformation(databasename, speicherplatz, informationsname)  
local path = system.pathForFile( databasename .. ".db", system.DocumentsDirectory )  
local db = sqlite3.open( path )  
  
for row in db:nrows("SELECT " .. informationsname .. " FROM levels WHERE id=" .. speicherplatz) do  
 if informationsname == "l1" then return row.l1  
 elseif informationsname == "l2"then return row.l2   
 elseif informationsname == "l3" then return row.l3   
 elseif informationsname == "l4" then return row.l4   
 elseif informationsname == "l5" then return row.l5   
 elseif informationsname == "l6" then return row.l6   
 elseif informationsname == "l7" then return row.l7   
 elseif informationsname == "l8" then return row.l8   
 elseif informationsname == "l9" then return row.l9   
 elseif informationsname == "l10" then return row.l10   
 end  
end  
  
end  

Could it maybe because of the updateRowInTable code ?
Please need some help :confused: [import]uid: 145807 topic_id: 30102 reply_id: 120651[/import]

Could it be that the database on your device is not up-to-date? if the levels table already exists but you have modified the table structure it will not-update what’s already on the device(at least with the code above). clearing out what’s in your sandbox on the Sim and clearing out the user data(i think) should remove the database on both systems.

Outside of that I can’t really help…I haven’t really had an issue with sqlite working on the sim but not on the device so I don’t have much else to suggest. [import]uid: 147305 topic_id: 30102 reply_id: 120656[/import]

Could you show me how? Sorry my English isnt that good to understand everything what you said . [import]uid: 145807 topic_id: 30102 reply_id: 120659[/import]

Found Problem + Solution simple as hell…
I always overrided my Game on Device but not the db now I deinstalled it and it worked… <. topic_id:="" reply_id:=""></.>