Code example for StatFs

Methods: getBlockSizegetFreeBlocksrestat

0
 
    } 
 
    private static long getAvailableInternalStorage() 
    { 
        StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
        stat.restat(Environment.getDataDirectory().getPath());
        long bytesAvailable = (long) stat.getFreeBlocks() * (long) stat.getBlockSize();
        long megAvailable = bytesAvailable / 1048576;
        return megAvailable;
    } 
 
    private static long getTotalInternalStorage() 
    { 
        StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
        long bytesAvailable = (long) stat.getBlockSize() * (long) stat.getBlockCount();
        long megAvailable = bytesAvailable / 1048576;
        return megAvailable;
 
    } 
Experience pair programming with AI  Get Codota for Java