Database won't save in Iphone5

My app works, but it doesn’t save on Iphone5, on all other devices it saves also in the Xcode Simulator but only in the Iphone5 my app won’t save

The device is case sensitive so one possibility is that you have named the file something and referring to it with different case.

everything is crystal clear, it reads that level 1 is the only thing unlocked, it has 0 stars, but whenever I finish level 1 all the stars that I acquired are not saved and level 2 is not yet unlocked. In other device progress is smooth, but in Iphone 5 its like this.

Can you post your saving/loading code and where you call your saving/loading code?  What version of Corona SDK are you using?

Here is my saving

db:exec([[UPDATE levels SET status = 'done' WHERE level = ']]..nextLevel..[[']])

I don’t know my version but I downloaded it 1st week of Feb this year

Have you done device debugging yet to check for errors? http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Where is the database saved to?

You can find your version under the About menu.

It is saved in the ResourcesDirectory

Version 2013.2100 (2013.12.7)

The ResourceDirectory is read only.  You need to create the database in system.DocumentsDirectory if you intended to write to it or update it.  If it’s prepopulated with data, you have to copy the database to the system.DocumentsDirectory.

With your suggestion I found a solution to one of my problems hahah so that will make it a 2 in 1 answer :slight_smile: thanks really :slight_smile:

BTW is there any fast way to copy the database? Like copy paste or am I gonna hardcode every tables and columns and rows

Try something like this

-- See if Database File Already Exists in Documents Directory path = system.pathForFile( "game.db", system.DocumentsDirectory ) file = io.open( path, "r" ) if( file == nil )then -- Doesn't Already Exist, So Copy it In From Resource Directory pathSource = system.pathForFile( "game.db", system.ResourceDirectory ) fileSource = io.open( pathSource, "r" ) contentsSource = fileSource:read( "\*a" ) -- Write Destination File in Documents Directory pathDest = system.pathForFile( "game.db", system.DocumentsDirectory ) fileDest = io.open( pathDest, "w" ) fileDest:write( contentsSource ) -- Done io.close( fileSource ) io.close( fileDest ) end

The device is case sensitive so one possibility is that you have named the file something and referring to it with different case.

everything is crystal clear, it reads that level 1 is the only thing unlocked, it has 0 stars, but whenever I finish level 1 all the stars that I acquired are not saved and level 2 is not yet unlocked. In other device progress is smooth, but in Iphone 5 its like this.

Can you post your saving/loading code and where you call your saving/loading code?  What version of Corona SDK are you using?

Here is my saving

db:exec([[UPDATE levels SET status = 'done' WHERE level = ']]..nextLevel..[[']])

I don’t know my version but I downloaded it 1st week of Feb this year

Have you done device debugging yet to check for errors? http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Where is the database saved to?

You can find your version under the About menu.

It is saved in the ResourcesDirectory

Version 2013.2100 (2013.12.7)

The ResourceDirectory is read only.  You need to create the database in system.DocumentsDirectory if you intended to write to it or update it.  If it’s prepopulated with data, you have to copy the database to the system.DocumentsDirectory.

With your suggestion I found a solution to one of my problems hahah so that will make it a 2 in 1 answer :slight_smile: thanks really :slight_smile:

BTW is there any fast way to copy the database? Like copy paste or am I gonna hardcode every tables and columns and rows