android中有三种类型的内存:
+内部存储器(完成)
+SdCard (完成)
+外部SD卡(外部存储卡-外部存储(FLASH)):如何获取其总大小,以及如何识别安卓中的external_sdcard目录??希望很快得到答案:)
发布于 2012-03-02 14:58:39
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
long bytesCount = (long)stat.getBlockSize() * (long)stat.getBlockCount();
return bytesCount;发布于 2016-11-02 02:43:28
如果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")https://stackoverflow.com/questions/7394152
复制相似问题