ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); //系统内存信息
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
am.getMemoryInfo(memInfo);
long availRAMsize = memInfo.availMem;//818774016
final StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());//调用该类来获取磁盘信息(而getDataDirectory就是内部存储)
long tcounts = statFs.getBlockCount();//总共的block数 3196073
long counts = statFs.getAvailableBlocks() ; //获取可用的block数 3029039
long size = statFs.getBlockSize(); //每格所占的大小,一般是4KB== 4096
long availROMSize = counts * size;//可用内部存储大小 12406943744
long totalROMSize = tcounts *size; //内部存储总大小 13091115008
final StatFs statFs1 = new StatFs(Environment.getExternalStorageDirectory().getPath());//调用该类来获取磁盘信息(而getExternalStorageDirectory就是外置存储)
long tcounts1 = statFs1.getBlockCount();//总共的block数 3196073
long counts1 = statFs1.getAvailableBlocks() ; //获取可用的block数 3029039
long size1 = statFs1.getBlockSize(); //每格所占的大小,一般是4KB== 4096
long availROMSize1 = counts1 * size1;//可用内部存储大小 12406943744
long totalROMSize1 = tcounts1 *size1; //内部存储总大小 13091115008
long totalROMSize2 = tcounts1 *size1; //内部存储总大小