Managing .json Files

So I was reading through the tutorials on reading and writing files and got to here: https://docs.coronalabs.com/guide/data/readWriteFiles/index.html#androidrestrict. I’m now thoroughly confused. Does this mean that for all of the image files of sprites I want to use that if I want to export to Android (even just for testing) I have to copy them over to the documents directory? Also I’ve opened up the documents directory via the simulator but don’t know how to actually create a file there during runtime. I currently am working on a multi-level puzzle game which stores data in the following format for world 1 right now:

[ {   "states":[    1,    0,    0,    0,    0,    0,    0,    0,    0   ],   "normalStarScores":[   0,    0,    0,    0,    0,    0,    0,    0,    0   ],   "reverseStarScores":[   0,    0,    0,    0,    0,    0,    0,    0,    0   ]  } ]

A 0 in the states array represent a locked level, 1 a new (open but incomplete, by the player) level, and 2 a completed level. The other two arrays representing the stars collected (0 for not collected, 1 for collected). This is currently in data-save.json (I also have a data-world.json however it is only read). Both are currently in scene/data in the resource directory.

So how do I actually make a new file in the documents directory and do I actually have to copy all of my graphics and read-only files over?

No, all your graphics can remain as they are.  If you want to store progress then you would write a json file to the documents directory.

This will explain how to do the file i/o - https://coronalabs.com/blog/2014/10/14/tutorial-saving-and-loading-lua-tables-with-json/

Thanks. So I’ve read that tutorial before but my problem now is just trying to wrap my head around how you actual write to a file if the file does not yet exist in the documents directory/how to physically create the .json file itself

Your json is real simple and can be made from game state objects.  Just do something like this

function saveData()   --create your structure to save   local data = {}   data.states = {1,2,3,4}   data.normalStarScores = {1,2,1,1}   data.reverseStarScores = {0,0,0,0}      --save it  local loadsave = require( "loadsave" )  -- Require the 'loadsave' module  loadsave.saveTable( data, "settings.json" ) end

You then extend when you want to save more data as your app grows

Ah thank you. That makes more sense now

No, all your graphics can remain as they are.  If you want to store progress then you would write a json file to the documents directory.

This will explain how to do the file i/o - https://coronalabs.com/blog/2014/10/14/tutorial-saving-and-loading-lua-tables-with-json/

Thanks. So I’ve read that tutorial before but my problem now is just trying to wrap my head around how you actual write to a file if the file does not yet exist in the documents directory/how to physically create the .json file itself

Your json is real simple and can be made from game state objects.  Just do something like this

function saveData()   --create your structure to save   local data = {}   data.states = {1,2,3,4}   data.normalStarScores = {1,2,1,1}   data.reverseStarScores = {0,0,0,0}      --save it  local loadsave = require( "loadsave" )  -- Require the 'loadsave' module  loadsave.saveTable( data, "settings.json" ) end

You then extend when you want to save more data as your app grows

Ah thank you. That makes more sense now