Question

I'm writing small media player for Android on DigiBoard(Evaluation Board). I want to use USB storage for playing music. I can plug USB, my board mount it(I see a notification) and when I use ADB shell and go to /mnt/ i have several folders, one of them is udisk and SD Card:

# cd mnt
cd mnt
# ls
ls
obb
shm
asec
extsd
udisk
sdcard
secure

I'm listing a proc/mounts content:

# cat mounts
cat mounts
rootfs / rootfs rw 0 0
ubi0_0 / ubifs rw,relatime 0 0
tmpfs /dev tmpfs rw,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/shm tmpfs rw,relatime,size=1024k,mode=775,uid=1000,gid=1003 0 0
/dev/block/vold/179:1 /mnt/sdcard vfat ro,dirsync,nosuid,nodev,noexec,relatime,u
id=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset
=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/179:1 /mnt/secure/asec vfat ro,dirsync,nosuid,nodev,noexec,relat
ime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,ioch
arset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /mnt/sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
/dev/block/vold/8:1 /mnt/udisk vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=
1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=is
o8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
#

I have here some paths, two of them are "valid" mnt/sdcard and mnt/udisk. I've read that entries with vfat are valid mounts, but /mnt/secure/asec have vfat property. I have application named ES File Explorer and I can see files in "udisk" folder: EZ output so it is possible to filter mounted sources. Can you tell me how to filter this? Are some folders in /mnt by default and i can list them/hardcode in app so I'll check their names?

Was it helpful?

Solution

OK, I've done it on my own. You need to read /proc/mounts file and filter its content:

if (entry.contains("vfat") && !entry.contains("secure")) {
    String absolutePath = entry.split(" ")[1];
}

entry is a single line form that file. In absolutePath you have direct path to mounted device like /mnt/sdcard or /mnt/udisk.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top