I'm using QtCreator and Qt for android.
I was trying to make a file dialog app on android,using QFileSystemModel.
And I'm debugging on my phone(HTC A9).
I can't see any other content on my phone except my package(QDir::currentPath()) but if I set to QDir::rootPath(), the file dialog shows nothing but / at beginning(nothing after I try to access it)
The console shows :
W libFileDialog.so: (null):0 ((null)): inotify_add_watch("/data/user") failed: "Permission denied"
W libFileDialog.so: (null):0 ((null)): inotify_add_watch("/data") failed: "Permission denied"
W libFileDialog.so: (null):0 ((null)): inotify_add_watch("/") failed: "Permission denied"
W libFileDialog.so: (null):0 ((null)): inotify_add_watch("/data") failed: "Permission denied"
W libFileDialog.so: (null):0 ((null)): inotify_add_watch("/data/user") failed: "Permission denied"
W libFileDialog.so: (null):0 ((null)): inotify_add_watch("/data/user/0") failed: "Permission denied"
I added permissions
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
But it still says inotify_add_watch failed blahblah...
And it works totally fine on windows.
And if I use virtual device to debug, it still denies sometimes but only denies permission when I try to set the root path of the model to some directory called (date, config... etc)
How should I fix that?
Or is it the problem about coding an android app with only C++ so it's telling me to go to learn JAVA?( I really want to stick to C++ :c )
code:
_fileModel = new QFileSystemModel;
_fileModel->setReadOnly(false);
_fileModel->setRootPath(QDir::rootPath());
_fileModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Files);
ui->listView->setModel(_fileModel);
I just read that after I need to request permission while running.
I called static java method to request permissions, and it's granted, but I still can't see the files. (only difference is that I can see /sdcard inside my virtual device.)