Sign up for the KDAB Newsletter
Stay on top of the latest news, publications, events and more.
Go to Sign-up
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:
But there are quite a few features that are missing, mostly due to these missing implementation or incompatible/limited Qt platform abstractions:
We've added all the above missing features to a new Qt (5.x & 6.x) shared storage library for Android. This library gives you complete access to documents and other files from shared storage.
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.
About KDAB
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications. In addition to being leading experts in Qt, C++ and 3D technologies for over two decades, KDAB provides deep expertise across the stack, including Linux, Rust and modern UI frameworks. With 100+ employees from 20 countries and offices in Sweden, Germany, USA, France and UK, we serve clients around the world.
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Upgrade your applications from Qt 5 to Qt 6 with KDAB’s migration services. Get a free migration assessment and join a hands-on workshop to prepare your team for a successful transition!
Learn more
4 Comments
20 - Nov - 2022
Ekkehard Gentz
Hi BogDan, just found this. (was mentioned here: https://bugreports.qt.io/browse/QTBUG-98974?focusedCommentId=677732&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-677732) really cool work :) This should help to get a great workaround because of ScopedSorage problems. In one of my customers apps I have 2 scenarios: 1. Open File Dialog, Select Files, copy them into AppData, then upload contents to server and delete from AppData 2. Save a downloaded File into a Folder Seems I can do this with your SharedStorage library :)
4 - Mar - 2024
xf Gao
this lib can operate file once only, I want to write another file cannot, the file can be create, but write data is zero bytes.
12 - Nov - 2024
Alex
Hi, Is it still needed in Qt 6.8 ?
12 - Nov - 2024
BogDan Vatra
AFAIK 6.8 added a few more features, but I don't know if there are all features implemented.