如何在android中找到内部(默认手机存储)和外部存储(可移动SD卡)?

发布于 2024-12-15 01:38:59 字数 350 浏览 5 评论 0原文

我的摩托罗拉手机具有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤星 2024-12-22 01:38:59

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.

冷清清 2024-12-22 01:38:59

尝试此代码,它返回所有存储文件夹名称。

在此处查看我的帖子:

https://stackoverflow.com/a/38930531/1733810

不要忘记添加权限。

访问外部存储

为了在外部存储上读取或写入文件,您的应用程序必须获取 READ_EXTERNAL_STORAGE 或 WRITE_EXTERNAL_STORAGE 系统权限。例如:

<manifest ...>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    ...
</manifest>

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:

<manifest ...>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    ...
</manifest>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文