I am trying to save game settings into a file. It works in the simulator but not on device. Here is the code I’m using:
local path = system.pathForFile( "data.txt", system.DocumentsDirectory )
-- io.open opens a file at path. returns nil if no file found
local file = io.open( path, "r" )
if file then
local line1 = (file:read("\*l"))
local line2 = (file:read("\*l"))
reverseValueText.text = line1
locationValueText.text = line2
line1 = nil
line2 = nil
io.close( file )
else
-- create file b/c it doesn't exist yet and add the default settings
file = io.open( path, "w+" )
file:write( "No\n", "Left\n" )
io.close( file )
end
(To me it seems that it fails to create the file data.txt on device but I’m not sure). All the files of my app are in one folder. Any ideas what to try next? [import]uid: 13507 topic_id: 11165 reply_id: 311165[/import]