public class

StatFs

extends Object
java.lang.Object
   ↳ android.os.StatFs

Class Overview

Retrieve overall information about the space on a filesystem. This is a Wrapper for Unix statfs().

Summary

Public Constructors
StatFs(String path)
Construct a new StatFs for looking at the stats of the filesystem at path.
Public Methods
int getAvailableBlocks()
The number of blocks that are free on the file system and available to applications.
int getBlockCount()
The total number of blocks on the file system.
int getBlockSize()
The size, in bytes, of a block on the file system.
int getFreeBlocks()
The total number of blocks that are free on the file system, including reserved blocks (that are not available to normal applications).
void restat(String path)
Perform a restat of the file system referenced by this object.
Protected Methods
void finalize()
Is called before the object's memory is being reclaimed by the VM.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public StatFs (String path)

Construct a new StatFs for looking at the stats of the filesystem at path. Upon construction, the stat of the file system will be performed, and the values retrieved available from the methods on this class.

Parameters
path A path in the desired file system to state.

Public Methods

public int getAvailableBlocks ()

The number of blocks that are free on the file system and available to applications. This corresponds to the Unix statfs.f_bavail field.

public int getBlockCount ()

The total number of blocks on the file system. This corresponds to the Unix statfs.f_blocks field.

public int getBlockSize ()

The size, in bytes, of a block on the file system. This corresponds to the Unix statfs.f_bsize field.

public int getFreeBlocks ()

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 statfs.f_bfree field. Most applications will want to use getAvailableBlocks() instead.

public void restat (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.

Protected Methods

protected void finalize ()

Is called before the object's memory is being reclaimed by the VM. This can only happen once the VM has detected, during a run of the garbage collector, that the object is no longer reachable by any thread of the running application.

The method can be used to free system resources or perform other cleanup before the object is garbage collected. The default implementation of the method is empty, which is also expected by the VM, but subclasses can override finalize() as required. Uncaught exceptions which are thrown during the execution of this method cause it to terminate immediately but are otherwise ignored.

Note that the VM does guarantee that finalize() is called at most once for any object, but it doesn't guarantee when (if at all) finalize() will be called. For example, object B's finalize() can delay the execution of object A's finalize() method and therefore it can delay the reclamation of A's memory. To be safe, use a ReferenceQueue, because it provides more control over the way the VM deals with references during garbage collection.