Android中的外置Sd卡(外部存储器)?

时间:2011-09-12 21:16:04

标签: android

android中有三种类型的内存:

+内存(DONE)

+ SdCard(DONE)

+外部SD卡(外部存储卡 - 外部存储(FLASH)):如何获取它的总大小以及如何识别android中的external_sdcard目录? 希望很快得到答案:)

2 个答案:

答案 0 :(得分:1)

StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
long bytesCount = (long)stat.getBlockSize() * (long)stat.getBlockCount();
return bytesCount;

答案 1 :(得分:0)

如果Environment.getExternalStorage...无效,请使用:

StatFs statFs = new StatFs(System.getenv("SECONDARY_STORAGE"));
float total_space = ((float)statFs.getBlockCount() * statFs.getBlockSize()) / 1048576;

// This will give in mega bytes. 

享受。希望这有用。

// For internal storage use this> System.getenv("EXTERNAL_STORAGE")
相关问题