如何以编程方式查找USB存储路径? [英] How to find USB storage path programmatically?

查看:83
本文介绍了如何以编程方式查找USB存储路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 USB 存储设备连接到我的手机并使用了

I connected USB storage to my phone and I used

getExternalFilesDirs("");

找到所有目录,包括sdcard和USB.

to find all directories including sdcard and USB.

sdcard路径正确出来,但是USB路径没有被函数出来.

The path of sdcard comes out correctly, but USB path does not come out by the function.

有没有办法找到USB的相对路径而不是绝对路径?

Is there anyway to find relative path of USB instead of absolute path?

我被这个问题困扰了几个星期,但一无所获.

I've been stuck at this problem for few weeks, but got nothing.

推荐答案

由于 Android 权限,您可能无法执行此操作,但这里还是建议.尝试阅读/proc/mounts 和 grep "sda1" 的内容.它会显示您的 USB 驱动器的安装点.

Due to Android permissions you may not be able to do this, but here's the recommendation anyways. Try to read the contents of /proc/mounts and grep "sda1". It'll show you the mount point of your USB drive.

这篇关于如何以编程方式查找USB存储路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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