Hi, Im working in a app and need to save data. I use a Json file, where i save questions
I do this:
local sceneName = …
local composer = require( “composer” )
local scene = composer.newScene( sceneName )
function scene:create (event)
local json = require( “json” )
local loadsave = require( “loadsave” )
local filename = system.pathForFile( “file.json”, system.DocumentsDirectory)
local t = json.decodeFile(filename)
local preguntas ={
{preg1=“Color favorito?”},
{preg2=“Dia favorito?”}
}
local encode = json.encode(preguntas)
loadsave.saveTable( preguntas, “file.json” )
local file = io.open (filename, “r”)
contents = file:read("*a")
texto = display.newText(“leer” …contents.preg1 ,200 ,200)
end
----- funciones ------
scene:addEventListener(“create”,scene)
I want to write preg1 in the screen but make a error.
Thanks!