[英]how to recognize external sd card mounted in the device and that device also have internal sd card?
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上,三星為系統分配了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..
}
}
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.