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

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 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
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on 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
      1
      • K kuzulis

        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 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.

        jsulmJ 1 Reply Last reply
        0
        • G Gourmet

          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 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
          0
          • C closx

            @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 last edited by
            #5

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

            1 Reply Last reply
            0
            • G Gourmet

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

              jsulmJ Online
              jsulmJ Online
              jsulm
              Lifetime Qt Champion
              wrote on 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
              3
              • jsulmJ jsulm

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

                • Login

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