Create folder/file on internal storage of mobile device
-
wrote on 5 Oct 2017, 08:10 last edited by chawila 10 May 2017, 08:20
i am developing an app that load stuff from the internet(server), so i want to store xml file on device to be accessible later even without internet.
Firstly i want to create a folder for my app where i can store all the files i want..
i tried the the following but its not working.QString appFolder(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/myappname"); QDir homePath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); //check and create to the writable path if (homePath.exists()){ homePath.mkdir("myappname"); }else{ QDir().mkpath(appFolder); } //just incase it was not created if (!homePath.cd("myappname")){ homePath.mkpath("myappname"); }
-
i am developing an app that load stuff from the internet(server), so i want to store xml file on device to be accessible later even without internet.
Firstly i want to create a folder for my app where i can store all the files i want..
i tried the the following but its not working.QString appFolder(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/myappname"); QDir homePath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); //check and create to the writable path if (homePath.exists()){ homePath.mkdir("myappname"); }else{ QDir().mkpath(appFolder); } //just incase it was not created if (!homePath.cd("myappname")){ homePath.mkpath("myappname"); }
i want somthing like these:
@chawila said in Create folder/file on internal storage of mobile device:
i tried the the following but its not working.
I am tired of guessing...
Maybe you could tell us what exactly isn't working and at least on what mobile platform you are on. That might help a little, don't you think? -
wrote on 5 Oct 2017, 12:47 last edited by chawila 10 May 2017, 12:48
i`m not sure about what u want..
device : HUAWEI P8 lite
android version : 5.0.1
i tested it by creating, writing and reading from file.
and it looks like it is working, however i cant find the location where it created the folder and file..'i mean when browsing on the phone'
-
i`m not sure about what u want..
device : HUAWEI P8 lite
android version : 5.0.1
i tested it by creating, writing and reading from file.
and it looks like it is working, however i cant find the location where it created the folder and file..'i mean when browsing on the phone'
@chawila
so all you need to know is whatQStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
returns? really?! -
wrote on 5 Oct 2017, 12:58 last edited by
@raven-worx said in Create folder/file on internal storage of mobile device:
QStandardPaths::AppDataLocation
I know what it return.
Returns the directory containing the user applications (either executables, application bundles, or shortcuts to them). This is a generic value. Note that installing applications may require additional, platform-specific operations. Files, folders or shortcuts in this directory are platform-specific.
what i want to know is how to create a folder exactly next to whatsapp folder on the image i attached..
-
@raven-worx said in Create folder/file on internal storage of mobile device:
QStandardPaths::AppDataLocation
I know what it return.
Returns the directory containing the user applications (either executables, application bundles, or shortcuts to them). This is a generic value. Note that installing applications may require additional, platform-specific operations. Files, folders or shortcuts in this directory are platform-specific.
what i want to know is how to create a folder exactly next to whatsapp folder on the image i attached..
@chawila said in Create folder/file on internal storage of mobile device:
what i want to know is how to create a folder exactly next to whatsapp folder on the image i attached..
well why not asking this in the first place. Instead of "it's not working".
Nevertheless, traverse over the other
QStandardPaths
and check what returnes the closest path.
The internal storage is not the same on all devices and Android versions. Normally it is something like/storage/emulated/0/
If non of the
QStandardPaths
return the desired path you will have to use JNI and call some methods on the Context (=Activity). E.g:
1/6