gpt4 book ai didi

android - 如何识别安装在设备中的外部 sd 卡和该设备也有内部 sd 卡?

转载 作者:行者123 更新时间:2023-11-30 04:07:54 26 4
gpt4 key购买 nike

if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))            
{
System.out.println("​sd card present");
}

通过使用此代码,我能够找到 SD 卡,但我无法识别它是哪张 SD 卡。那是内置的 sd 还是外置的...

http://androidforums.com/samsung-galaxy-s2-t/557831-am-i-saving-sdcard-not.html请引用此链接一次......

SGS2 Samsung 上,有一个 2 GB 的系统分区,剩余的 14 GB 分区并通过其挂载点/sdcard 被识别为 sd 卡。除此之外,我们还可以在该设备中安装外部可移动 SD 卡。那么如何通过编程识别外置移动SD卡。

最佳答案

String sdcardpath = null;
File[] faFiles = new File("/mnt").listFiles();
abc: {
for (File file : faFiles) {
if (file.isDirectory()) {
String pathMain = "" + file.getAbsolutePath();
Log.v("@@@@@@@@@@@@@@@@", "222222222222" + pathMain);
if (pathMain.indexOf("ext") > 0&&pathMain.startsWith("/mnt/")) {
File fp = new File(pathMain);
if (fp.canWrite()) {
Log.v("@@@@@@@@@@@@@@@@", "33333333333333333"
+ pathMain);
//external sd card is there..
sdcardpath = pathMain;
break abc;
}
else{

}
} else {
if (pathMain.indexOf("sd") > 0) {
File fp = new File(pathMain);
if (fp.canWrite()) {
Log.v("@@@@@@@@@@@@@@@@", "33333333333333333"+ pathMain);
sdcardpath = pathMain;

//internal sd card is there..
}

}
}
}
}
}

关于android - 如何识别安装在设备中的外部 sd 卡和该设备也有内部 sd 卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11329137/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com