2011-06-19 73 views

回答

2

事實證明就可以了。運行此代碼似乎會返回我內部存儲中剩餘的相應字節數。不確定關於Environment.getDataDirectory()的可靠性

public static long remainingLocalStorage() 
{ 
    StatFs stat = new StatFs(Environment.getDataDirectory().getPath()); 
    stat.restat(Environment.getDataDirectory().getPath()); 
    long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getAvailableBlocks(); 
    return bytesAvailable; 
}