ANDROID: Accessing CIFS Shares in Java

5.1k views Asked by At

I'm writing my first Android app, which is more or less going to be a mount point manager. Local mounts and NFS mounts have been easy, but I'm not sure of how to go about CIFS shares.

Ideally, after selecting a host, a list of CIFS shares would be displayed. At the bare minimum, I should be able to enter a CIFS URI/share string and mount it (eg: //192.168.1.100/mount_point). I'm thinking of EStrongs, where you can select a host, and it will display shares, which you can then further explore.

I've seen jCIFS (I think this is what Astro uses), and I've seen mention of the cifs.ko module on xda-developers. Are there any other standard approaches? Any tips/recommendations on how to go about using jCIFS or cifs.ko and doing this in general? I would prefer not to have to gain root access.

3

There are 3 answers

0
TryTryAgain On BEST ANSWER

Fellow Androider here, I've looked into various protocols in the past and this is what I found:

If it has to be CIFS then I would recommend jCIFS. Astro does use it, as you mentioned and EStrongs does as well. And...so does AndSMB by lysesoft. So, I'm pretty sure that's the 'go to' standard approach.

If you are looking into only supporting SMB, you may be interested in this as an alternative: http://java-source.net/open-source/network-clients/jftp

Also, for other protocols, this is a great list to peruse: http://java-source.net/open-source/network-clients

Hope that helps.

0
P Varga On

Because Android is Linux, you can use kernel drivers, but loading those requires root, or you can use FUSE, which is supposedly supported since Gingerbread (haven't tried it myself), or indeed you can use a Java library like JCIFS

0
Chris Hertel On

A quick Wireshark capture shows that EStrongs also uses jCIFS, so that would be my recommendation as well. jCIFS was written to be a CIFS client toolkit, so it should be adaptable to your project goals. It does not "mount" the remote file system, per se., but gives you access to files, directories, share listings, etc. How you present that information is up to you.

Another resource would be Implementing CIFS, an online book about the internals of the SMB/CIFS protocol suite. In particular, take a look at Appendix D, which covers the SMB URL format. The SMB URL is preferred over the mock UNC format used in the original post (above).