I've hit a snag in development regarding saving application settings on Android.
Currently I'm using the following:

Qt Code:
  1. QSettings *settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "Company","Application-Name", 0);
To copy to clipboard, switch view to plain text mode 

This works perfectly on Windows, Linux, MacOS, iOS, but it does not work on Android. After searching around here and a few other places (stackoverflow), I see most people using something similar to the following to declare the exact file name/path:

Qt Code:
  1. QString m_path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
  2. QString m_filename = "config.ini";
  3. QString m_settingsfile = m_path + "/" + m_filename;
  4. QSettings *settings = new QSettings(m_settingsfile, QSettings::IniFormat);
To copy to clipboard, switch view to plain text mode 

However this does not work for me either.
I get no errors on compilation on any system (including android), and debugging shows no errors. I assume the problem is a permissions issue, but I can't seem to track it down without any errors anywhere.

I have the following in my AndroidManifest.xml


<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23"/>

<uses-permission android:name="android.permission.WRITE_SECURE_SETT INGS"/>
<uses-permission android:name="android.permission.PERSISTENT_ACTIVI TY"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_ST ORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STO RAGE"/>
<uses-permission android:name="android.permission.WRITE_PROFILE"/>

Within my application I'm saving information with something like:
Qt Code:
  1. void mainWindow::addInfo(){
  2. QString pass;
  3. if(!INFO.hasLoaded()){
  4. //New settings data - need to prompt for a password
  5. pass = QInputDialog::getText(this, tr("Create New Password"), tr("Password:"), QLineEdit::Password);
  6. if(pass.isEmpty()){ return; } //cancelled
  7. QString chk;
  8. while(chk!=pass){
  9. chk = QInputDialog::getText(this, tr("Verify New Password"), tr("Password:"), QLineEdit::Password);
  10. if(chk.isEmpty()){ return; } //cancelled
  11. }
  12. }
  13. Host host(ui->line_ip->text(), ui->line_desc->text(), ui->line_name->text(), ui->line_field->text());
  14. HOSTS << host;
  15. if( !HOSTS.saveHostInformation(settings, pass) ){
  16. //Could not save information
  17. QMessageBox::warning(this, tr("Error"), tr("Could not save host information to disk") );
  18. }
  19. updateInfo();
  20. ui->info_add->setVisible(false);
  21. }
To copy to clipboard, switch view to plain text mode 


I know my overall code is fine, because it works on every platform other than Android. My issue is with something android specific, but I haven't been able to track it down. Probably because it's something simple and I keep overlooking it.

Can someone point me in the right direction?