标签:
//File path = Environment.getDataDirectory();//手机内置空间
1、获取SD卡的路径
File path = Environment.getExternalStorageDirectory();
2、获取扇区
StatFs stat = new StatFs(path.getPath());
3、获取一个扇区大小
long blockSize = stat.getBlockSize();
4、获取空闲的扇区
long availableBlocks = stat.getAvailableBlocks();
5、获取总空间的扇区数
long all = stat.getBlockCount();
String avail = Formatter.formatFileSize(this, availableBlocks * blockSize);//获取总空间数
String all_count = Formatter.formatFileSize(this, all * blockSize);//获取空闲的内存
view.setText("空闲的内存:" + avail +" 总空间数:" + all_count);
标签:
原文地址:http://www.cnblogs.com/zzw1994/p/4885932.html