Unsolved Cannot create a directories and files
-
Hi all! I have not been able to solve this problem for a very long time, so I'm writing to you.
In shot: permission to change internal memory isn’t issued and folders/files aren't create (on most devices).I have a multi-platform application that has a log system. Logging occurs in a separate file, which is created when the application starts. On the Window - everything works fine. On Android – it's never work except my personal smartphone (Android 5.1). On other devices, neither directories nor files are even created. At the same time, only on my phone the application does have the necessary permissions (work with memory and the network), on the others (at least one that is for tests, Android 8.1.0) - they are not and they are no question about it during installation. However, even when the application is given permission to change the memory, the result is same.
Here is creenshot of my AndroidManifest.xml:
And test code where i'm trying to create dir or file:
QString testPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/Hom loc"; QDir().mkdir(testPath); QFile(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/UHomLoc log.txt").open(QIODevice::ReadWrite); testPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/AD loc"; QDir().mkdir(testPath); QFile(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/UADLoc log.txt").open(QIODevice::ReadWrite); testPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/GD loc"; QDir().mkdir(testPath); QFile(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/UGDLoc log.txt").open(QIODevice::ReadWrite);
I hope for your help!
-
Hi,
Just a wild guess but are you requesting the correct write permissions on Android ?
-
@SGaist said in Cannot create a directories and files:
Hi,
Just a wild guess but are you requesting the correct write permissions on Android ?
Hey! If you're about AndroidManifest setting - then yes, I'm pretty sure that these are right ones. These options are offered in topics on this issue, i also scrolled through all the options and think so. There are no such thing as "Read_internal_storage" or "Write_internal_storage"
UPD: Yeap https://developer.android.com/training/data-storage
It seems that these permissions just aren't give during installation and user can't issue them after :\