'Qt and Android 11: accessing file in download folder
I developed an app using QT 5.15 that need to read some kind of files in Android Download folder. All it's OK until Android 9. In Android 10 I added the manifest flag "requestLegacyExternalStorage=true" and it works. From Android 11 I can't access any files in Download folder. Only my app generated files can be read. But I need to import files downloaded from email or Google Drive.
This is related to the new Scoped storage policy but I can't find any example for QT.
Please help me!
Thanks
Solution 1:[1]
Use Storage Access Framework ACTION_OPEN_DOCUMENT to let the user select a file from Download directory.
Solution 2:[2]
In Android 11
you can access Download
folder, but only for the files
you've created.
For all other files (i.e. ones you did not create):
I'm afraid, you'll have to use SAF
(Storage Access Framework) in your case.
The problem that there is no Qt code can be available (until Qt Team implement it), because it must be implemented on Java
side.
There is no native API (e.g. C++
) is available. I.e. you can't use any C++
functions to work with files.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | blackapps |
Solution 2 | Alexander Dyagilev |