Saving settings - permissions?

Do I need to add any Android permissions to allow reading/writing of game settings?

I’m loading settings in my game using this:

-- load the settings local loadsave = require("loadsave") local M = loadsave.loadTable("gam3000settings.json") if( not M ) then       --Create the default settings     M = {}     M.scanDuration = 2     M.monsterProbability = 4 M.earliest = 7 M.latest = 10 M.scareSound = 1     loadsave.saveTable(M, "gam3000settings.json") end return M

Then later, when I exit the screen that changes settings, I write them out again:

loadsave.saveTable(settings, "gam3000settings.json")

Obviously I can’t know what “loadsave” does, but if it just persists the settings to a local file in the app’s private storage, then no, you don’t need additional permissions for that.

Not sure where I got “loadsave”, but here it is.

The routine seems to work on the Android device I have (Kindle Fire).

With this info, still no need for special Android permissions in the build.settings file?

local \_ = {} local json = require("json") local DefaultLocation = system.DocumentsDirectory local RealDefaultLocation = DefaultLocation local ValidLocations = {    [system.DocumentsDirectory] = true,    [system.CachesDirectory] = true,    [system.TemporaryDirectory] = true } function \_.saveTable(t, filename, location)     if location and (not ValidLocations[location]) then      error("Attempted to save a table to an invalid location", 2)     elseif not location then       location = DefaultLocation     end          local path = system.pathForFile( filename, location)     local file = io.open(path, "w")     if file then         local contents = json.encode(t)         file:write( contents )         io.close( file )         return true     else         return false     end end function \_.loadTable(filename, location)     if location and (not ValidLocations[location]) then      error("Attempted to load a table from an invalid location", 2)     elseif not location then       location = DefaultLocation     end     local path = system.pathForFile( filename, location)     local contents = ""     local myTable = {}     local file = io.open( path, "r" )     if file then         -- read all contents of file into a string         local contents = file:read( "\*a" )         myTable = json.decode(contents);         io.close( file )         return myTable     end     return nil end function \_.changeDefault(location) if location and (not location) then error("Attempted to change the default location to an invalid location", 2) elseif not location then location = RealDefaultLocation end DefaultLocation = location return true end return \_

You should not need any privs specifically for that.

Rob

Obviously I can’t know what “loadsave” does, but if it just persists the settings to a local file in the app’s private storage, then no, you don’t need additional permissions for that.

Not sure where I got “loadsave”, but here it is.

The routine seems to work on the Android device I have (Kindle Fire).

With this info, still no need for special Android permissions in the build.settings file?

local \_ = {} local json = require("json") local DefaultLocation = system.DocumentsDirectory local RealDefaultLocation = DefaultLocation local ValidLocations = {    [system.DocumentsDirectory] = true,    [system.CachesDirectory] = true,    [system.TemporaryDirectory] = true } function \_.saveTable(t, filename, location)     if location and (not ValidLocations[location]) then      error("Attempted to save a table to an invalid location", 2)     elseif not location then       location = DefaultLocation     end          local path = system.pathForFile( filename, location)     local file = io.open(path, "w")     if file then         local contents = json.encode(t)         file:write( contents )         io.close( file )         return true     else         return false     end end function \_.loadTable(filename, location)     if location and (not ValidLocations[location]) then      error("Attempted to load a table from an invalid location", 2)     elseif not location then       location = DefaultLocation     end     local path = system.pathForFile( filename, location)     local contents = ""     local myTable = {}     local file = io.open( path, "r" )     if file then         -- read all contents of file into a string         local contents = file:read( "\*a" )         myTable = json.decode(contents);         io.close( file )         return myTable     end     return nil end function \_.changeDefault(location) if location and (not location) then error("Attempted to change the default location to an invalid location", 2) elseif not location then location = RealDefaultLocation end DefaultLocation = location return true end return \_

You should not need any privs specifically for that.

Rob