So, if the application data is sandboxed, how do we migrate data that used to be in shared locations to the sandbox?
I was using the Documents location to keeps users presets, but now I will need to migrate those files to inside the app From your experience what is the most appropriated QStandardPath location to store user data from Android 11 onwards? > On 3 Sep 2021, at 14:53, Jérôme Godbout <jgodb...@dimonoff.com> wrote: > > Humm not sure about all the enum, but the one I was using did not. Maybe we > can do a build and print those path for both Android 11 and 12 to compare, > but my guess is sthat should be the same. > > The Android 11 bring is that it lock down as private the application folder, > other application can no more access the files/folders of another > application. So if you were sending files/folders path to another application > for them to open it will no more work. They are now sandboxed. > > A bit like iOS application have been for a while, but on iOS you can define a > group to allow special access to given application as long as the domain > match the group. > > From: Nuno Santos <nuno.san...@imaginando.pt > <mailto:nuno.san...@imaginando.pt>> > Date: Friday, September 3, 2021 at 9:33 AM > To: Jérôme Godbout <jgodb...@dimonoff.com <mailto:jgodb...@dimonoff.com>> > Cc: ekke <e...@ekkes-corner.org <mailto:e...@ekkes-corner.org>>, Qt Interest > <interest@qt-project.org <mailto:interest@qt-project.org>> > Subject: Re: [Interest] Save / load file contents on android > > But doesn’t QStandardPath resolve to different locations depending if > legacyExternalStorage is enabled or not? > > > On 3 Sep 2021, at 13:51, Jérôme Godbout <jgodb...@dimonoff.com > <mailto:jgodb...@dimonoff.com>> wrote: > > Take care with the eternal storage opt out will no more be possible after > November. We will need to target SDK 12 to publish to the store. So the 11 > opt out flag will no more be possible (November for existing application, for > new application it’s already started since august). > > Try to push an update asap so your user can migrate the data to the > application proper folder. Other application cannot access the files anymore. > If your file are already into the application data folder you do not have to > worry much you still can access them easily. > > But the QStandard path have work fine for us so far. You can check the > actual path it resolve to on this page (scroll a bit down to see the path for > Android): > https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum > <https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum> > > > > From: Interest <interest-boun...@qt-project.org > <mailto:interest-boun...@qt-project.org>> on behalf of ekke > <e...@ekkes-corner.org <mailto:e...@ekkes-corner.org>> > Date: Friday, September 3, 2021 at 5:47 AM > To: Nuno Santos <nuno.san...@imaginando.pt <mailto:nuno.san...@imaginando.pt>> > Cc: Qt Interest <interest@qt-project.org <mailto:interest@qt-project.org>> > Subject: Re: [Interest] Save / load file contents on android > > Hi Nuno, > > Am 03.09.21 um 11:05 schrieb Nuno Santos: > Ekke, > > I have been experiencing some inconsistencies with Android file access using > QStandardPaths, mostly now that I’m preparing the ground for Android 11 > support. From Android 11 onwards, there will be changes in the way an app can > access filesystem resources. > > This problem started when one of apps was in some systems using legacy file > access while in others was already using the new storage approach. In order > to temporary fixes this issues I have set the requestLegacyExternalStorage to > true, however, soon this will end as in Android 11 it will be ignored. > I'm in the same situation as you ;-) have set requestLegacyExternalStorage ATM > last weeks had much work moving all my projects from Qt 5.13.2 to 5.15.5, so > I can prepare for Qt 6.2 > now there will be 3 weeks vacation > then support of Android 11 file storage will be high on my TODO list > ... and hoping then to find some docs / tips HowTo support this from Qt ;-) > ekke > > One of the current challenges I’m facing the moving/copying resources from > legacy storage to new storage when using QStandardPaths and QFileDialog. > > How have you been handling Android 11 support and data migration from older > versions? > > Are you able to do it just with Qt stuff or do you need to handle some of the > things with native android API’s? > > Thanks! > > Nuno > > On 31 Aug 2021, at 13:38, ekke <e...@ekkes-corner.org > <mailto:e...@ekkes-corner.org>> wrote: > > Am 31.08.21 um 14:12 schrieb Wilhelm Meier via Interest: > Hi all, > > does anybody have a minimum working example how to load / save json file > contents (auscii contents) to / from a file on android. > > I made several attempts, but I get weird filenames and I'm not able to > load the stored file. > > thx > _______________________________________________ > Interest mailing list > Interest@qt-project.org <mailto:Interest@qt-project.org> > https://lists.qt-project.org/listinfo/interest > <https://lists.qt-project.org/listinfo/interest> > Hi, > some snippets HowTo save a JSON. use QVariantMap for a JSON Object or > QVariantList for JSON Array > > QJsonDocument jda = QJsonDocument::fromVariant(myQVariantMap); > QByteArray buffer = jda.toJson(); > saveTestFile("_my_test.json", buffer); > ... > > void DataServer::saveTestFile(const QString& fileName, const QByteArray& > buffer) > { > QString filePath = mDataManager->dataPath(fileName); > QFile saveFile(filePath); > if (!saveFile.open(QIODevice::WriteOnly)) { > qWarning() << "Couldn't open file to write " << filePath; > return; > } > qint64 bytesWritten = saveFile.write(buffer); > saveFile.close(); > qDebug() << "Bytes written: " << bytesWritten << " to: " << filePath; > } > .... > > // Android: AppDataLocation works out of the box, iOS you must create the > DIR first !! > mDataRoot = > QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).value(0); > mDataPath = mDataRoot+"/data/"; > ---- > and reading is similar > > jda = QJsonDocument::fromJson(dataFile.readAll()); > dataFile.close(); > if(!jda.isArray()) { > myMap = jda.toVariant().toMap(); > } else { > myList = jda.toVariant().toList(); > } > ----- > hope it helps > _______________________________________________ > Interest mailing list > Interest@qt-project.org <mailto:Interest@qt-project.org> > https://lists.qt-project.org/listinfo/interest > <https://lists.qt-project.org/listinfo/interest>
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest