Application preferences location

On Windows I write these to the registry. Are there similar functions on MacOS & Linux? Or do you just write to the Shared Application Data folder?

On macOS you use plist files which are sorta xml files. There is an API - I use CFPreferencesMBS.

The plist files are for simple storage. And they are slow if you save lots of data. In addition to the plist file I have an SQLite database in Application Support.

Thanks @Beatrix_Willius I only have 3 strings to save, but this is going to be an open-source project so don’t want to use paid plugins.

All my prefs go into an SQLite database. That gets stored along with user data in an application folder, which itself lives in the Documents folder. Makes it easy for the user to move it to another machine.

1 Like

Save them into a text file (each one in its line) and read them sequencially.
Nothing fancy to use unless these are sensible informations (passwords…).
In folder using the application’s name (to avoid potential conflicts).

I stored custom color definitions using this way.

For 3 string preferences values make some simple xml or json in Application Support.

1 Like

I use plists on all platforms and always put them in ApplicationData. JSON would be fine, too.

You can store all your preferences in a Dictionary and then write it to disk as a string using GenerateJSON, read it back using ParseJSON.

Similarly, my system just uses a JSONItem for easy i/o and lookup. I constructed a module around it for syntactic sugar; but you could just read and write into a global JSONItem.

When I noticed that adding my settings module to the project increased the build size by 1.4mb because it added the SQLite dylib for no other reason, I moved all my projects to a JSONItem storage system.

Thank you all. I think I’ll use the dictionary/json option.