Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Create folder/file on internal storage of mobile device
Forum Updated to NodeBB v4.3 + New Features

Create folder/file on internal storage of mobile device

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 2 Posters 4.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • chawilaC Offline
    chawilaC Offline
    chawila
    wrote on last edited by chawila
    #1

    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:
    0_1507191217841_Screenshot_2017-10-05-10-05-50.png

    raven-worxR 1 Reply Last reply
    0
    • chawilaC chawila

      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:
      0_1507191217841_Screenshot_2017-10-05-10-05-50.png

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @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?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • chawilaC Offline
        chawilaC Offline
        chawila
        wrote on last edited by chawila
        #3

        @raven-worx

        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'

        raven-worxR 1 Reply Last reply
        1
        • chawilaC chawila

          @raven-worx

          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'

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @chawila
          so all you need to know is what QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) returns? really?!

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1
          • chawilaC Offline
            chawilaC Offline
            chawila
            wrote on last edited by
            #5

            @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-worxR 1 Reply Last reply
            0
            • chawilaC chawila

              @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-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @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:

              • getExternalFilesDir()
              • getFilesDir()
              • getExternalStoragePublicDirectory()
                etc.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved