As @Mathias_Westerdahl suggested sys.save() and sys.load() will do the trick. Remember to use sys.get_save_file() to get a writable path to the file.
local some_data = { score = 12345, name = "Foobar" }
local filename = sys.get_save_file("myapp", "mysavefile")
local success = sys.save(filename, some_data)
local loaded_data = sys.load(filename)
Note that there is a limitation on the size of the table that you can persist using sys.save() and a limitation on the keys.
You can also use the io.* functions to store data in your own format or larger amounts of data:
local filename = sys.get_save_file("myapp", "mysavefile")
local file, error = io.open(filename, "wb")
if not file then
print(error)
return
end
file:write("somedata")
file:flush()
file:close()
local file, error = io.open(filename, "rb")
if not file then
print(error)
return
end
local somedata = file:read("*a")