So I’m working on saves for my app right now, the problem is, when I test it, the simulator crashes… It stops responding and crashes.
My code is as follows:
[lua]
local saveData = “saveScore”
local path = system.pathForFile( “ScoreSave.txt”, system.DocumentsDirectory )
local file = io.open( path, “w” )
file:write( saveData )
io.close( file )
file = nil
–opening the file
local path = system.pathForFile( “ScoreSave.txt”, system.DocumentsDirectory )
local file = io.open( path, “r” )
local saveData = file:read( “*a” )
io.close( file )
file = nil
local function onSystemEvent( event )
if ( event.type == “applicationSuspend” ) then
saveScore()
print(“saveScore”)
end
end
Runtime:addEventListener( “system”, onSystemEvent )
[/lua]