如何在android中找到内部(默认手机存储)和外部存储(可移动SD卡)?
我的摩托罗拉手机具有 12GB 内部存储空间和可移动 SD 卡功能。
在 DDMS 文件资源管理器中,我的内部手机存储 (12GB) 安装为 SD 卡,我的可移动 SD 卡安装为 sdcard-ext。
使用“Environment.getExternalStorageDirectory().getAbsolutePath()”方法我可以获得目录“/mnt/sdcard”。 有没有什么方法可以让我找到可移动SD卡的绝对路径?...即,这将返回我“/mnt/sdcard-ext”
My Motorola Phone has 12GB internal storage and Removable Sd card feature.
In DDMS file explorer my internal phone storage(12GB) is mounted as sdcard and my removable sdcard is mounted as sdcard-ext.
Using "Environment.getExternalStorageDirectory().getAbsolutePath()" method i can able to get the directory "/mnt/sdcard".
Is there is any method through which i can find the absolute path of my removable sdcard?... ie.,which will return me "/mnt/sdcard-ext"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Android框架目前仅支持一个大容量存储设备,因此很难管理多个(您可以尝试解析
/proc/mounts
以获取所有已安装的设备)。但您可以使用他们构建的摩托罗拉 API,因为这个事实。
查看摩托罗拉“外部”存储 API。
The Android framework currently supports only one mass storage device, so it's hard to manage multiple (you could try to parse
/proc/mounts
to get all mounted devices).But you can use Motorolas API that they built because of that fact.
Check out the Motorola "External" Storage API.
尝试此代码,它返回所有存储文件夹名称。
在此处查看我的帖子:
https://stackoverflow.com/a/38930531/1733810
不要忘记添加权限。
访问外部存储
为了在外部存储上读取或写入文件,您的应用程序必须获取 READ_EXTERNAL_STORAGE 或 WRITE_EXTERNAL_STORAGE 系统权限。例如:
Try this code its return all storage folder name.
Check My post here:
https://stackoverflow.com/a/38930531/1733810
Don't forget to add permission.
Getting access to external storage
In order to read or write files on the external storage, your app must acquire the READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE system permissions. For example: