Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Android root folder read access
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.
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.
@kuzulis Root File Explorer works with root folder on devices without superuser access (root). And not only this FM can do that.
closx last edited by
@Gourmet maybe you can try QStorageInfo instead of QDir?
#include <QStorageInfo> QStorageInfo mySinfo = QStorageInfo::root(); tv->setRootIndex( fsm->setRootPath( mySinfo.rootPath() ) );
@closx I have tried right now. Unfortunately result is the same. Empty.
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."
Gourmet last edited by Gourmet
@jsulm it requires root privileges for "write" operations. Another one FM - Total Commander can read root folder. See screenshot made on non-rooted device.