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. Issue with mkpath on Android
Forum Updated to NodeBB v4.3 + New Features

Issue with mkpath on Android

Scheduled Pinned Locked Moved Solved Mobile and Embedded
androidmkpath
6 Posts 3 Posters 703 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.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by
    #1

    I have an application which has been developed in C++ on Windows, but can be used on Linux (desktop and embedded) without issues. The application generates quite a number of files in a data folder. Those files are filled using std ofstreams. The files are structured in different folders. The folders are generated on the fly by QDir::mkpath.

    Now on Android there seems to be an issue with the generation of the topmost data folder which is typically structured
    <country code>.<company>.<application> on Android.

    When this folder has to be generated as well mkpath has a problem and the folder is not generated.

    When folder is already available the performance of all subsequent folders is normal without an issue.

    Any idea what am I missing?

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What root path are you using for these folders ?

      At least on Android you need to use QStandardPath::AppDataLocation. But don't forget to first create the directory returned by the writablePath call the first time you want to access it. Its name is valid however it does not exist yet.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      K 2 Replies Last reply
      2
      • SGaistS SGaist

        Hi,

        What root path are you using for these folders ?

        At least on Android you need to use QStandardPath::AppDataLocation. But don't forget to first create the directory returned by the writablePath call the first time you want to access it. Its name is valid however it does not exist yet.

        K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        @SGaist

        The data is under /storage/emulated/0/Android/data which is the internal data storage.

        Thanks for the lead I am going follow this up.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          What root path are you using for these folders ?

          At least on Android you need to use QStandardPath::AppDataLocation. But don't forget to first create the directory returned by the writablePath call the first time you want to access it. Its name is valid however it does not exist yet.

          K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @SGaist said in Issue with mkpath on Android:

          Hi,

          What root path are you using for these folders ?

          At least on Android you need to use QStandardPath::AppDataLocation. But don't forget to first create the directory returned by the writablePath call the first time you want to access it. Its name is valid however it does not exist yet.

          I guess you meant https://doc.qt.io/qt-5/qstandardpaths.html#writableLocation with QStandardPaths::DataLocation

          At least that I got to work apparently on Android 10.
          Android 9 is still less cooperative. At least the files are not written there, but must be written somewhere since the application does not crash. I can't find the files.

          Vote the answer(s) that helped you to solve your issue(s)

          KroMignonK 1 Reply Last reply
          0
          • K koahnig

            @SGaist said in Issue with mkpath on Android:

            Hi,

            What root path are you using for these folders ?

            At least on Android you need to use QStandardPath::AppDataLocation. But don't forget to first create the directory returned by the writablePath call the first time you want to access it. Its name is valid however it does not exist yet.

            I guess you meant https://doc.qt.io/qt-5/qstandardpaths.html#writableLocation with QStandardPaths::DataLocation

            At least that I got to work apparently on Android 10.
            Android 9 is still less cooperative. At least the files are not written there, but must be written somewhere since the application does not crash. I can't find the files.

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by KroMignon
            #5

            @koahnig I guess the files are written under /data/user/0/<packagename>/files/

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            K 1 Reply Last reply
            1
            • KroMignonK KroMignon

              @koahnig I guess the files are written under /data/user/0/<packagename>/files/

              K Offline
              K Offline
              koahnig
              wrote on last edited by
              #6

              @KroMignon said in Issue with mkpath on Android:

              @koahnig I guess the files are written under /data/user/0/<packagename>/files/

              You are correct that this is the path shown with writableLocation. It is also generated under /storage/emulated/0/Android/data/<packagename>/files. However, you cannot simply this /data/user/0/<packagename>/files/ for absolute path' with ofstream under C++. These files are not generated.

              I was previously wrong. The issue is the same for Android 9 and Android 10.

              When using /storage/emulated/0/Android/data/<packagename>/files this might be used as basis for absolute path' generation and std::ofstream of C++.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0

              • Login

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