Handling user settings on file, how?

Ok, I created my first APP, it runs on the Virtual and also a Real phone. :slight_smile: Now I added the properties file but it doesn’t get saved or maybe even created. I tried to search the file but couldn’t find it… maybe is the way Android works, so I need to learn that…

PropertiesFile::Options propOptions;
propOptions.applicationName = "7 Segments";
configFile = File(File::getSpecialLocation(File::SpecialLocationType::commonDocumentsDirectory).getFullPathName() + "Seven Segments Settings.xml");
userSettings = new PropertiesFile(configFile, propOptions);

To access files outside the sandbox, the app needs to ask for permission using the RuntimePermissions class. On most folders I was using, including userDocumentsDirectory and userMusicDirectory I needed to request RuntimePermissions::writeExternalStorage

I would try different locations, if you can find some inside the app’s sandbox, maybe userApplicationDataDirectory, but I am not an Android expert.

1 Like

Oh yeah, thank you so much!


Android is tricky, here is the folder i tried, it seems like w/o success

For android and other mobile platforms have a look into the RuntimePermissions class (am on mobile, hence no link… you should be able to find it in the docs)

Thank you Daniel, with RuntimePermission and following code, file has been created successfully.
File configFile = File("/sdcard/Download/MySettings.xml");
configFile.create();