Accessing a shared directory from my android app

159 Views Asked by At

I have configured Samba on my Raspberry Pi to have a shared folder on my LAN. The access is user and passwordfree.

I can access it from my PC on windows and even on my android phone with some file explorer.

Problem is that I can't access it from my app running on android. "Le folder does not exist".

const QString REMOTE_PATH = "//RASPBERRYPI/public/pic";

QDir fromDir(REMOTE_PATH );
fromDir.setFilter(QDir::Files | QDir::NoSymLinks);
fromDir.setNameFilters(QStringList() << "*.png");
int remote_count = fromDir.entryList().count();

if (fromDir.exists())
{
// copy files etc ...
}

Here is the permissions in the manifest file :

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CAMERA"/>

I use Qt6.4.3, the program is ok when I run it on Windows Desktop, problem is only on Android (13 for me).

Thanks

1

There are 1 best solutions below

4
blackapps On

REMOTE_PATH = "//RASPBERRYPI/public/pic";

That, a network path, is not usable with QDir::FIles.

You have to use a samba library like jcifs or smbj.