Unable to save QSettings on Android
I've hit a snag in development regarding saving application settings on Android.
Currently I'm using the following:
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:
Code:
QString m_path
= QStandardPaths
::writableLocation(QStandardPaths
::ConfigLocation);
QString m_settingsfile
= m_path
+ "/" + m_filename;
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
Quote:
<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:
Code:
void mainWindow::addInfo(){
if(!INFO.hasLoaded()){
//New settings data - need to prompt for a password
if(pass.isEmpty()){ return; } //cancelled
while(chk!=pass){
if(chk.isEmpty()){ return; } //cancelled
}
}
Host host(ui->line_ip->text(), ui->line_desc->text(), ui->line_name->text(), ui->line_field->text());
HOSTS << host;
if( !HOSTS.saveHostInformation(settings, pass) ){
//Could not save information
QMessageBox::warning(this, tr
("Error"), tr
("Could not save host information to disk") );
}
updateInfo();
ui->info_add->setVisible(false);
}
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?