外部USB存储在Android [英] External USB storage on Android

查看:148
本文介绍了外部USB存储在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一篇数字板(评估板)小型媒体播放器为Android。我想使用USB存储播放音乐。我可以插USB,我​​的板安装它(我看到一个通知),当我使用ADB壳,去到/ mnt /我有几个文件夹,其中有一个是移动U盘和SD卡:

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

我列出一个PROC /坐骑内容:

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
#

我这里有一些路径,其中两个是有效MNT / SD卡和MNT /移动U盘。我读过,比如vfat项是​​有效的坐骑,但到/ mnt /安全/ ASEC有VFAT财产。我已经申请ES命名的文件资源管理器,我可以看到在移动U盘文件夹中的文件:

因此能够过滤装源。你能告诉我如何筛选呢?一些文件夹/默认mnt中,我可以列出他们/硬code在应用程序,所以我会检查他们的名字?

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: 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?

推荐答案

OK,我已经做到了我自己。
你需要阅读的/ proc /坐骑文件和过滤的内容:

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];
}

条目是​​单线形成该文件。在absolutePath你必须喜欢到/ mnt / SD卡或到/ mnt /移动U盘安装设备的直接路径。

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

这篇关于外部USB存储在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆