Storing settings for an app

I am working on a cross-platform (iOS and Android) app, and would like the user to be able to store some settings. In this case, the settings cover whether to use inches, feet, yards, meters, centimeters, or millimeters.

On many iOS apps, such settings are stored in the OS-level “Settings” app, which makes a slot in its menu for each app that is storing settings. I don’t see this on my Android phone.

Is there a standard way on Corona to deal with this? I am happy to store settings in an internal database, but if there is a crossover/native way to do it, I would like that better.

Most people simply save the data to their Docuements Directory.  A very easy way to do this is to have your settings in a Lua table and use JSON to encode the data into a simple string and write that string out.  Every time there is a change, save the change.  As long as the app is running it should have the latest settings and you only need to read the settings on a cold start.  There is a tutorial with a couple of functions that manage this for you:

http://coronalabs.com/blog/2014/10/14/tutorial-saving-and-loading-lua-tables-with-json/

There are of course other ways to do this.  Several community members have built methods of just storing key-value pairs and so on. 

Rob

I was already in the process of the Documents directory technique.  It just occurred to me that there is the other paradigm that is Apple iOS only.  Since there is no Corona widget to get to the iOS Settings gizmo, I will just proceed with the JSON method.

I use preference library for saving settings and other stuff.

You can find it in the code exchange -> http://code.coronalabs.com/code/preference-library-save-data-files-tables-numbers-strings-and-boolean

Most people simply save the data to their Docuements Directory.  A very easy way to do this is to have your settings in a Lua table and use JSON to encode the data into a simple string and write that string out.  Every time there is a change, save the change.  As long as the app is running it should have the latest settings and you only need to read the settings on a cold start.  There is a tutorial with a couple of functions that manage this for you:

http://coronalabs.com/blog/2014/10/14/tutorial-saving-and-loading-lua-tables-with-json/

There are of course other ways to do this.  Several community members have built methods of just storing key-value pairs and so on. 

Rob

I was already in the process of the Documents directory technique.  It just occurred to me that there is the other paradigm that is Apple iOS only.  Since there is no Corona widget to get to the iOS Settings gizmo, I will just proceed with the JSON method.

I use preference library for saving settings and other stuff.

You can find it in the code exchange -> http://code.coronalabs.com/code/preference-library-save-data-files-tables-numbers-strings-and-boolean