Android Shared Storage Qt Wrapper A New Qt (5.x & 6.x) Library for Complete Shared Storage Access
In this article, I’d like to talk about Android storage.
In recent Android versions, Google decided, for a good reason, to restrict the access to the SD card. This means, even if your application will have the old READ/WRITE_EXTERNAL_STORAGE permissions declared and granted, you won’t be able to freely access the SD Card contents like you used to.
In order to access the SD card or any other shared storage places, you’ll have to use the Android shared storage API. The good news is that, with this API, you’ll be able to access any file from any storage location (i.e. from gdrive), without any special code.
As you probably already know, a long time ago, my colleagues added to Qt 5.13 the following basic support features for shared storage:
- create a new file using an existing content provider (i.e. QFileDialog)
- open an existing file using an existing content provider (i.e. QFileDialog)
- list directory content* using an URL from an existing content provider (i.e. QFileDialog)
But there are quite a few features that are missing, mostly due to these missing implementation or incompatible/limited Qt platform abstractions:
- create a new file in an existing folder URI.
- create a new folder in an existing folder URI.
- remove a file/folder.
- rename a file/folder.
- move a file/folder to another place.
- copy a file/folder to another place.
- get file mime type.
Until we manage to add the missing pieces to Qt’s platform abstraction, or if you still need to use Qt 5.x, you can use our shared storage library.
Here you can find an example that shows how to use this library to perform most of the common operations.
Another thing that I personally don’t like about the current Qt platform abstraction is that FileDialog QML Type will add QWidgets to your pure QML application. I hope we’ll address this in the next Qt versions as well.