public ArrayList getMountPaths() {//反射获取路径
ArrayList data = new ArrayList();
StorageManager storageManager = (StorageManager)context.getSystemService(Context.STORAGE_SERVICE);
try {
List volumes = storageManager.getStorageVolumes();
Class<?> storageVolumeClazz = Class.forName("android.os.storage.StorageVolume");
Method getPath = storageVolumeClazz.getMethod("getPath");
Method isRemovable = storageVolumeClazz.getMethod("isRemovable");
for (int i = 0; i < volumes.size(); i++) {
StorageVolume storageVolume = volumes.get(i);//获取每个挂载的StorageVolume
String storagePath = (String) getPath.invoke(storageVolume); //获取路径
boolean isRemovableResult = (boolean) isRemovable.invoke(storageVolume);//是否可移除
String description = storageVolume.getDescription(context);
if(isRemovableResult)
{
Log.e(TAG, "getUSBPaths: "+storagePath+" "+ description);
data.add(storagePath);
}
}
}
catch (Exception e) {
e.printStackTrace();
}
return data;
}
刚接触PICO VR 遇到些问题
通过上面代码打印信息 获取到U盘路径 getUSBPaths: /mnt/media_rw/4470-B7E2 aigo U 盘
但是读取不了
mount 命令 返回的信息
/dev/block/vold/public:8_97 /mnt/media_rw/4470-B7E2 vfat rw,dirsync,nosuid,nodev,noexec,noatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
同样的代码 在手机中可以读到U盘目录
怎么才能正确的遍历U盘里的目录
怎么才能读取到 /mnt/media_rw/4470-B7E2 这个目录 没有ROOT 或者有什么其他方法吗
可以给个DEMO吗 必有重谢