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. How to save files under Android/data?
Forum Updated to NodeBB v4.3 + New Features

How to save files under Android/data?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 1.3k 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.
  • B Offline
    B Offline
    Bremenpl
    wrote on last edited by
    #1

    Hello there,
    I am developing an Android application using Qt 5.13.0. Using the https://doc.qt.io/qt-5.9/qstandardpaths.html I am tryng to figure out which path will lead me to the Android/data directory:

    0_1567496011020_3459201c-1787-43bd-af62-d127f9927d60-image.png

    I have set the package name in the android manifest file to com.company.appname.
    I would appreciate all help.

    lprzenioslo.zut.edu.pl

    Pradeep P NP 1 Reply Last reply
    1
    • B Bremenpl

      Hello there,
      I am developing an Android application using Qt 5.13.0. Using the https://doc.qt.io/qt-5.9/qstandardpaths.html I am tryng to figure out which path will lead me to the Android/data directory:

      0_1567496011020_3459201c-1787-43bd-af62-d127f9927d60-image.png

      I have set the package name in the android manifest file to com.company.appname.
      I would appreciate all help.

      Pradeep P NP Offline
      Pradeep P NP Offline
      Pradeep P N
      wrote on last edited by Pradeep P N
      #2

      Hi @bremenpl

      Can you please check QStandardPaths & enum QStandardPaths::StandardLocation.

      namespace {
      
      void createAppFolder(const QString &folder)
      {
          QDir dir(folder);
          dir.mkpath(".");
      }
      }
      
      
      QString defaultFolderPath()
      {
          const QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
          if (!QFileInfo::exists(path))
              createAppFolder(path); 
          return path;
      }
      

      All the best.

      Pradeep Nimbalkar.
      Upvote the answer(s) that helped you to solve the issue...
      Keep code clean.

      B 1 Reply Last reply
      2
      • Pradeep P NP Pradeep P N

        Hi @bremenpl

        Can you please check QStandardPaths & enum QStandardPaths::StandardLocation.

        namespace {
        
        void createAppFolder(const QString &folder)
        {
            QDir dir(folder);
            dir.mkpath(".");
        }
        }
        
        
        QString defaultFolderPath()
        {
            const QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
            if (!QFileInfo::exists(path))
                createAppFolder(path); 
            return path;
        }
        

        All the best.

        B Offline
        B Offline
        Bremenpl
        wrote on last edited by Bremenpl
        #3

        @pradeep-p-n Hi, thanks for answer,
        I have already tried QStandardPaths::AppDataLocation enum value. It places the file in a location that is not accessible to the user (/data). Instead, I am looking for an enum that would access /storage/emulated/0/Android/data, since this path is accessible "outside" the application.

        lprzenioslo.zut.edu.pl

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Bremenpl
          wrote on last edited by Bremenpl
          #4

          With these piece of code I have checked all the available locations:

          qDebug() << "Config path set to:" << configPath;
          for (int i = 0; i <= static_cast<int>(QStandardPaths::AppConfigLocation); i++)
          {
          	const QString tmp = QStandardPaths::writableLocation(static_cast<QStandardPaths::StandardLocation>(i));
          	qDebug() << "Path" << i << tmp;
          }
          

          Seems like Qt cannot save the file where I need to:

          Path 0 "/data/user/0/org.qtproject.example.mri/files"
          Path 1 "/storage/emulated/0/Documents"
          Path 2 ""
          Path 3 ""
          Path 4 "/storage/emulated/0/Music"
          Path 5 "/storage/emulated/0/Movies"
          Path 6 "/storage/emulated/0/Pictures"
          Path 7 "/data/user/0/org.qtproject.example.mri/cache"
          Path 8 "/data/user/0/org.qtproject.example.mri/files"
          Path 9 "/data/user/0/org.qtproject.example.mri/files"
          Path 10 "/data/user/0/org.qtproject.example.mri/cache"
          Path 11 "/storage/emulated/0"
          Path 12 "/data/user/0/org.qtproject.example.mri/cache"
          Path 13 "/data/user/0/org.qtproject.example.mri/files/settings"
          Path 14 "/storage/emulated/0/Download"
          Path 15 "/data/user/0/org.qtproject.example.mri/cache"
          Path 16 "/data/user/0/org.qtproject.example.mri/files/settings"
          Path 17 "/data/user/0/org.qtproject.example.mri/files"
          Path 18 "/data/user/0/org.qtproject.example.mri/files/settings"
          

          Any ideas?

          lprzenioslo.zut.edu.pl

          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