- /**
- * 获得SD卡总大小
- *
- * @return
- */
- private String getSDTotalSize() {
- File path = Environment.getExternalStorageDirectory();
- StatFs stat = new StatFs(path.getPath());
- long blockSize = stat.getBlockSize();
- long totalBlocks = stat.getBlockCount();
- return Formatter.formatFileSize(MainActivity.this, blockSize * totalBlocks);
- }
- /**
- * 获得sd卡剩余容量,即可用大小
- *
- * @return
- */
- private String getSDAvailableSize() {
- File path = Environment.getExternalStorageDirectory();
- StatFs stat = new StatFs(path.getPath());
- long blockSize = stat.getBlockSize();
- long availableBlocks = stat.getAvailableBlocks();
- return Formatter.formatFileSize(MainActivity.this, blockSize * availableBlocks);
- }
- /**
- * 获得机身内存总大小
- *
- * @return
- */
- private String getRomTotalSize() {
- File path = Environment.getDataDirectory();
- StatFs stat = new StatFs(path.getPath());
- long blockSize = stat.getBlockSize();
- long totalBlocks = stat.getBlockCount();
- return Formatter.formatFileSize(MainActivity.this, blockSize * totalBlocks);
- }
- /**
- * 获得机身可用内存
- *
- * @return
- */
- private String getRomAvailableSize() {
- File path = Environment.getDataDirectory();
- StatFs stat = new StatFs(path.getPath());
- long blockSize = stat.getBlockSize();
- long availableBlocks = stat.getAvailableBlocks();
- return Formatter.formatFileSize(MainActivity.this, blockSize * availableBlocks);
- }
androd i获取 SD卡 总容量 可用空间 内存大小 可用内存
最新推荐文章于 2022-04-26 17:36:36 发布