I am working on a mobile app, using Qt/C++, right now focusing on Android. My app needs to store some permanent data, in a private and secure way (not accessible to other apps, protected as much as possible):
Thanks.
When you install an app (either from the Google Play Store or through a downloaded apk file), Android places that into the device's app folder. That's /data/app/your_package_name for most apps. Some encrypted apps use /data/app-private/your_package_name.
Qt for Android enables you to develop Qt applications for Android devices, and supports a wide range of features and use-cases. To download and install Qt for Android, follow the instructions on the Getting Started with Qt for Android page. To build Qt from source, see Building from Source.
You can use external storage if the data that your application stores can be used by other applications. Additionally, if the file stored by your application is huge, such as a video, you can save it to external storage. You can use external storage to keep the data even after uninstalling the application.
App data is the data that is downloaded or generated as part of a device's content - for instance, downloaded books or music, while cache files are temporary files many programs generate while in use, such as saved portions of websites you visit in a browser.
Android maintains a standard storage for applications under the path /data/user/0
, where each application gets storage space. so if you have an application named org.qtproject.example.myApp
, Android automatically creates storage space for this app:
/data/user/0/org.qtproject.example.myApp
The settings are stored under the files
folder of this path, as ../files/.config/OrganizationName/AppName.conf
When you want to store information in Android you don't use absolute paths, instead you specify the location of your storage using Qt QStandardPaths
which usually returns location under the application path mentioned above, so for example to store a file mySomeFile
, you would set the path using QStandardPaths
like:
auto path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
auto fileName= path + "/mySomeFile";
and the file is stored as :
/data/user/0/org.qtproject.example.myApp/files/mySomeFile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With