FileDocCategorySizeDatePackage
StatFs.javaAPI DocAndroid 5.1 API4312Thu Mar 12 22:22:10 GMT 2015android.os

StatFs

public class StatFs extends Object
Retrieve overall information about the space on a filesystem. This is a wrapper for Unix statvfs().

Fields Summary
private android.system.StructStatVfs
mStat
Constructors Summary
public StatFs(String path)
Construct a new StatFs for looking at the stats of the filesystem at {@code path}. Upon construction, the stat of the file system will be performed, and the values retrieved available from the methods on this class.

param
path path in the desired file system to stat.

        mStat = doStat(path);
    
Methods Summary
private static android.system.StructStatVfsdoStat(java.lang.String path)

        try {
            return Os.statvfs(path);
        } catch (ErrnoException e) {
            throw new IllegalArgumentException("Invalid path: " + path, e);
        }
    
public intgetAvailableBlocks()

deprecated
Use {@link #getAvailableBlocksLong()} instead.

        return (int) mStat.f_bavail;
    
public longgetAvailableBlocksLong()
The number of blocks that are free on the file system and available to applications. This corresponds to the Unix {@code statvfs.f_bavail} field.

        return mStat.f_bavail;
    
public longgetAvailableBytes()
The number of bytes that are free on the file system and available to applications.

        return mStat.f_bavail * mStat.f_bsize;
    
public intgetBlockCount()

deprecated
Use {@link #getBlockCountLong()} instead.

        return (int) mStat.f_blocks;
    
public longgetBlockCountLong()
The total number of blocks on the file system. This corresponds to the Unix {@code statvfs.f_blocks} field.

        return mStat.f_blocks;
    
public intgetBlockSize()

deprecated
Use {@link #getBlockSizeLong()} instead.

        return (int) mStat.f_bsize;
    
public longgetBlockSizeLong()
The size, in bytes, of a block on the file system. This corresponds to the Unix {@code statvfs.f_bsize} field.

        return mStat.f_bsize;
    
public intgetFreeBlocks()

deprecated
Use {@link #getFreeBlocksLong()} instead.

        return (int) mStat.f_bfree;
    
public longgetFreeBlocksLong()
The total number of blocks that are free on the file system, including reserved blocks (that are not available to normal applications). This corresponds to the Unix {@code statvfs.f_bfree} field. Most applications will want to use {@link #getAvailableBlocks()} instead.

        return mStat.f_bfree;
    
public longgetFreeBytes()
The number of bytes that are free on the file system, including reserved blocks (that are not available to normal applications). Most applications will want to use {@link #getAvailableBytes()} instead.

        return mStat.f_bfree * mStat.f_bsize;
    
public longgetTotalBytes()
The total number of bytes supported by the file system.

        return mStat.f_blocks * mStat.f_bsize;
    
public voidrestat(java.lang.String path)
Perform a restat of the file system referenced by this object. This is the same as re-constructing the object with the same file system path, and the new stat values are available upon return.

        mStat = doStat(path);