You should be able to store that number into an array, then encode that array into JSON. Later decode it back into a table with the number still inside.
local score = 10 local scoreTable = {score} local path = system.pathForFile( "scores", system.DocumentsDirectory ) local file = io.open( path, "w" ) if file then local contentsScores = json.encode( scoreTable ) file:write( contentsScores ) io.close( file ) end
And then decode it later
local path = system.pathForFile( "scores", system.DocumentsDirectory ) local file = io.open( path, "r" ) if file then local contents = file:read( "\*a" ) local savedScores = json.decode( contents ) score = savedOptions[1] io.close( file ) end
Just remember to nil out the path, file and contents variables between methods.