public long getSDTotalSize() { /*获取存储卡路径*/ File sdcardDir= Environment.getExternalStorageDirectory(); /*StatFs 看文件系统空间使用情况*/ StatFs statFs=new StatFs(sdcardDir.getPath()); long blockSize= statFs.getBlockSizeLong(); long totalSize=statFs.getBlockCountLong(); return blockSize*totalSize; } /** * 获得sd卡剩余容量,即可以大小 * @return */ public long getSdAvaliableSize() { File path=Environment.getExternalStorageDirectory(); StatFs statFs=new StatFs(path.getPath()); long blockSize=statFs.getBlockSizeLong(); long availableBlocks=statFs.getAvailableBlocksLong(); return blockSize*availableBlocks; } /** * 获得机身内存大小 * @return */ public long getRomTotalSize() { File path=Environment.getDataDirectory(); StatFs statFs=new StatFs(path.getPath()); long blockSize=statFs.getBlockSizeLong(); long tatalBlocks= statFs.getBlockCountLong(); return blockSize*tatalBlocks; } /** * 获得机身可用内存 * @return */ private long getRomAvailableSize() { File path=Environment.getDataDirectory(); StatFs statFs=new StatFs(path.getPath()); long blockSize=statFs.getBlockSizeLong(); long availableBlocks=statFs.getAvailableBlocksLong(); return blockSize*availableBlocks; }