Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-98012

QSettings filename doesn't handle content:// URIs on Android

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.2, 6.6.0 Beta1
    • Core: Other
    • None
    • Android
    • Next

    Description

      I wrote this small snippet to reproduce the issue. Basically when a content:// uri is provided to QSettings it will not save anything to the location, however if a file is provided everything works fine. This example also works correctly on Desktop.

      QFile works correctly in both cases - so it's not a permission issue.

      QString download_location=QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);  // this returns storage/emulated/... This also requires write external storage permission but the issue can be reproduced in other locations
      
      #ifdef CONTENT_URI
      filename=QFileDialog::getSaveFileName(this, "save", download_location); // will return "content://com.android.providers.downloads.documents/document/206"
      #else
      filename=download_location+"/settings.ini" // will return "/storage/emulated/0/Download/settings.ini"
      #endif 
      
      qDebug()<<filename; 
      QSettings set(filename,QSettings::IniFormat, this); 
      set.setValue("test",123); 
      set.setValue("test2",456); 
      set.sync();

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qtandroidteam Qt Android Team
              adisuciu Adrian Suciu
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes