我怎样才能获得外部SD卡路径为Android 4.0+? [英] How can I get external SD card path for Android 4.0+?

查看:133
本文介绍了我怎样才能获得外部SD卡路径为Android 4.0+?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

三星Galaxy S3拥有extrenal SD卡插槽,可安装到的/ mnt / extSdCard

Samsung Galaxy S3 has an extrenal SD card slot, which is mounted to /mnt/extSdCard.

我的问题是:如何通过类似 Environment.getExternalStorageDirectory得到这个路径()?这将返回 MNT / SD卡,我找不到外接SD卡的API。 (或可移动USB存储设备上的一些片)

My question is: how to get this path by something like Environment.getExternalStorageDirectory()? This will return mnt/sdcard, and I can't find API for external SD card. (Or removable USB storage on some tablets)

感谢您!

推荐答案

我想用你需要使用这个外部SD卡:

I guess to use the external sdcard you need to use this:

new File("/mnt/external_sd/")

new File("/mnt/extSdCard/")

在你的情况......

in your case...

在替换 Environment.getExternalStorageDirectory的()

我的作品。您应该检查什么在目录MNT第一和工作从那里。

Works for me. You should check whats in the directory mnt first and work from there..

您应该使用某种类型的选择方法,选择要使用的SD卡:

You should use some type of selection method to choose which sdcard to use:

File storageDir = new File("/mnt/");
if(storageDir.isDirectory()){
    String[] dirList = storageDir.list();
    //TODO some type of selecton method?
}

这篇关于我怎样才能获得外部SD卡路径为Android 4.0+?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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