在android中获取可移动的SD卡路径 [英] get removable sd card path in android

查看:135
本文介绍了在android中获取可移动的SD卡路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在android中获取extSdcard路径?

How can i get extSdcard path in android?

有2个存储空间,第一个外部存储空间,所有手机都有它,但有第二个存储空间被调用可移动存储(micro sdcard)。

There are 2 storage, first external storage in which all the phones have it but there is second storage which is called removable storage (micro sdcard).

我想在android中获取micro sdcard的路径,这怎么可能?

I want to get the path to the micro sdcard in android, how is that possible?

推荐答案

从KitKat开始,您可以访问获取该目录的方法:

Starting from KitKat, you have access to a method to get that directory :

Context.getExternalFilesDirs()

请注意,如果SD卡不是,它可能会返回null在访问期间安装或移动。此外,您可能需要将这些权限添加到清单文件中:

Note that it may return null if the SD card is not mounted or moved during the access. Also, you might need to add these permissions to your manifest file :

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

显然有些用户在使用此方法时遇到问题,而不是返回SD卡路径。我发现了一些关于它如何工作的有用信息以及它如何不依赖于这篇文章

Apparently some users had trouble with this method, not returning the SD card path. I found some useful informations on how it can works and how it can not depending on the device on this post.

这篇关于在android中获取可移动的SD卡路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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