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. Android root folder read access
Forum Updated to NodeBB v4.3 + New Features

Android root folder read access

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
7 Posts 4 Posters 1.4k Views
  • 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.
  • G Offline
    G Offline
    Gourmet
    wrote on 10 Jul 2019, 18:02 last edited by
    #1

    Following code:

        QTreeView* tv = new QTreeView(this);
        QFileSystemModel* fsm = new QFileSystemModel(this);
        tv->setModel( fsm );
    1:    tv->setRootIndex( fsm->setRootPath( "//mnt/" ) ); // Android & Linux Ok
    2:   //tv->setRootIndex( fsm->setRootPath( QDir::rootPath() ) ); // Linux Ok, Android not
    

    Code under label 1: in Android and Linux opens folder /mnt and gives it contents. But if comment it then uncomment code under label 2: - it works properly only in desktop Linux (even without root privileges). In Android it gives empty tree. Just nothing. Probably this is related to access rights but I cannot find anything about read access to root folder in Android. All Android file system managers give read access to root folder without root privileges. How do they do that? What yet required to do to get read access in Qt5 application? Is anybody here who solved this?

    Please answer only if you do know answer. Do not tell about READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions. Application definitely has both - without it setRootPath( "//mnt/" ) cannot work.

    C 1 Reply Last reply 11 Jul 2019, 12:02
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on 11 Jul 2019, 07:13 last edited by
      #2

      Android file system managers give read access to root folder without root privileges

      What? It is surprise for Google.

      You need in the root access privileges to do that. It is not the Qt issue.

      G 1 Reply Last reply 11 Jul 2019, 09:53
      1
      • K kuzulis
        11 Jul 2019, 07:13

        Android file system managers give read access to root folder without root privileges

        What? It is surprise for Google.

        You need in the root access privileges to do that. It is not the Qt issue.

        G Offline
        G Offline
        Gourmet
        wrote on 11 Jul 2019, 09:53 last edited by
        #3

        @kuzulis Root File Explorer works with root folder on devices without superuser access (root). And not only this FM can do that.

        J 1 Reply Last reply 12 Jul 2019, 05:51
        0
        • G Gourmet
          10 Jul 2019, 18:02

          Following code:

              QTreeView* tv = new QTreeView(this);
              QFileSystemModel* fsm = new QFileSystemModel(this);
              tv->setModel( fsm );
          1:    tv->setRootIndex( fsm->setRootPath( "//mnt/" ) ); // Android & Linux Ok
          2:   //tv->setRootIndex( fsm->setRootPath( QDir::rootPath() ) ); // Linux Ok, Android not
          

          Code under label 1: in Android and Linux opens folder /mnt and gives it contents. But if comment it then uncomment code under label 2: - it works properly only in desktop Linux (even without root privileges). In Android it gives empty tree. Just nothing. Probably this is related to access rights but I cannot find anything about read access to root folder in Android. All Android file system managers give read access to root folder without root privileges. How do they do that? What yet required to do to get read access in Qt5 application? Is anybody here who solved this?

          Please answer only if you do know answer. Do not tell about READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions. Application definitely has both - without it setRootPath( "//mnt/" ) cannot work.

          C Offline
          C Offline
          closx
          wrote on 11 Jul 2019, 12:02 last edited by
          #4

          @Gourmet maybe you can try QStorageInfo instead of QDir?

          #include <QStorageInfo>
          QStorageInfo mySinfo = QStorageInfo::root();
          tv->setRootIndex( fsm->setRootPath( mySinfo.rootPath() ) );
          

          bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
          tag me (like @closx) if you are answering to me, so I can notice :D

          G 1 Reply Last reply 11 Jul 2019, 19:41
          0
          • C closx
            11 Jul 2019, 12:02

            @Gourmet maybe you can try QStorageInfo instead of QDir?

            #include <QStorageInfo>
            QStorageInfo mySinfo = QStorageInfo::root();
            tv->setRootIndex( fsm->setRootPath( mySinfo.rootPath() ) );
            
            G Offline
            G Offline
            Gourmet
            wrote on 11 Jul 2019, 19:41 last edited by
            #5

            @closx I have tried right now. Unfortunately result is the same. Empty.

            1 Reply Last reply
            0
            • G Gourmet
              11 Jul 2019, 09:53

              @kuzulis Root File Explorer works with root folder on devices without superuser access (root). And not only this FM can do that.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 12 Jul 2019, 05:51 last edited by
              #6

              @Gourmet said in Android root folder read access:

              Root File Explorer works with root folder on devices without superuser access (root)

              This seems to be wrong:
              "File Explorer Root Browser is a fully featured file manager & root browser for rooted superusers to take control of their Android device and root files & folders."
              From https://play.google.com/store/apps/details?id=com.jrummy.root.browserfree&hl=en

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              G 1 Reply Last reply 13 Jul 2019, 17:53
              3
              • J jsulm
                12 Jul 2019, 05:51

                @Gourmet said in Android root folder read access:

                Root File Explorer works with root folder on devices without superuser access (root)

                This seems to be wrong:
                "File Explorer Root Browser is a fully featured file manager & root browser for rooted superusers to take control of their Android device and root files & folders."
                From https://play.google.com/store/apps/details?id=com.jrummy.root.browserfree&hl=en

                G Offline
                G Offline
                Gourmet
                wrote on 13 Jul 2019, 17:53 last edited by Gourmet
                #7

                @jsulm it requires root privileges for "write" operations. Another one FM - Total Commander can read root folder. See screenshot made on non-rooted device.

                alt text

                1 Reply Last reply
                0

                1/7

                10 Jul 2019, 18:02

                • Login

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