StatFs getFreeBlocks - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for StatFs getFreeBlocks method.

This code example shows how to use the following methods:getAvailableBlocks, getBlockCount, getBlockSize, getFreeBlocks
This code example shows how to use the following methods:getAvailableBlocks, getBlockCount, getBlockSize, getFreeBlocks
		 
		test(); 
	} 
 
	private void test() { 
		StatFs sf = new StatFs(getFilesDir().getParent());
		Log.d(TAG , "getFilesDir().getParent():" + getFilesDir().getParent());
		Log.d(TAG, "sf.getAvailableBlocks():" + sf.getAvailableBlocks());
		Log.d(TAG, "sf.getBlockCount()" + (double)sf.getBlockCount());
		Log.d(TAG, "sf.getBlockSize()" + (double)sf.getBlockSize());
		Log.d(TAG, "sf.getFreeBlocks()" + (double)sf.getFreeBlocks());
		 
	} 
 
	 
} 
6
CodeRank
This code example shows how to use the following methods:getAvailableBlocks, getBlockCount, getBlockSize, getFreeBlocks
     *  
     * @return xx MB 
     */ 
    protected static long readSystemAvailSize() { 
        File root = Environment.getRootDirectory();
        StatFs sf = new StatFs(root.getPath());
        long blockSize = sf.getBlockSize();
        long blockCount = sf.getBlockCount();
        long availCount = sf.getAvailableBlocks();
        long freeCount = sf.getFreeBlocks();
 
        Log.d("Swapper", "block size:" + blockSize + ",block avail:" + blockCount + ",total size:"
                + blockSize * blockCount / 1024 + "KB");
        Log.d("Swapper", "block num:" + availCount + ",avail size:" + availCount * blockSize / 1024
                + "KB" + "Free size:" + freeCount);
 
        return (availCount * blockSize) / (1024 * 1024);
    } 
 
    protected static long readSdCardAvailSize() { 
6
CodeRank
This code example shows how to use the following methods:getBlockSize, getFreeBlocks
        return false; 
    } 
 
    public int getFreeSdDataByte() 
    { 
        StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
        return statFs.getBlockSize()* statFs.getFreeBlocks();
        //kjjk 
    } 
 
    public int getFreeDeviceDataByte() 
    { 
        StatFs statFs = new StatFs("/");
        return statFs.getBlockSize()* statFs.getFreeBlocks();
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:getBlockSize, getFreeBlocks
	 * Get the free space on the SDcard 
	 *  
	 * @return 
	 */ 
	public static long getFreeSpaceOnSDCard() { 
		StatFs cardStatistics = new StatFs(getDirectory().toString());
		long freeSpace = (long) cardStatistics.getBlockSize()
				* cardStatistics.getFreeBlocks();
		return freeSpace;
	} 
 
	/** 
	 * Check if the device has an SDcard. 
	 *  
	 * @return 
	 */ 
	public static boolean isMounted() { 
		return android.os.Environment.getExternalStorageState().equals(
				android.os.Environment.MEDIA_MOUNTED);
	} 
5
CodeRank
This code example shows how to use the following methods:getBlockSize, getFreeBlocks
public class StorageUtil { 
 
	private static final String TAG = StorageUtil.class.getName();
 
	public static long remainExternalStorage() { 
		StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
		return (long) stat.getFreeBlocks() * (long) stat.getBlockSize();
	} 
 
	/** 
	 * 지정된 경로의 폴더를 생성하고 결과를 반환한다. 
	 * @param path 생성할 폴더의 절대경로 
	 * @return 이미 폴더가 존재하거나 생성 실패시 false 반환 , 만들었을 경우 true 반환 
	 */ 
	public static boolean makeFolder(String path)
	{ 
		File file = new File(path);
 
		if(file.exists() && file.isDirectory())
			return false; 
5
CodeRank
This code example shows how to use the following methods:getBlockSize, getFreeBlocks
	 *  
	 * @return the cache remaining 
	 */ 
	public int cacheRemaining() { 
		File filesDir = mContext.getFilesDir();
		StatFs stats = new StatFs(filesDir.getPath());
		int free = stats.getFreeBlocks() * stats.getBlockSize();
		return free;
	} 
 
	/** 
	 * Write a stream to disk. 
	 * writes a HTTP entity to the specified filename and location on disk 
	 *  
	 * @param in 
	 *            the input stream 
	 * @param file 
	 *            the file to store it in 
	 * @param storeInHashedDirectory 
	 *            use a hashed directory name 
4
CodeRank
This code example shows how to use the following methods:getBlockSize, getFreeBlocks, restat
        st.restat("/data");
        return st.getFreeBlocks();
    } 
     
    long getFreeStorageSize(StatFs st) {
        st.restat("/data");
        return (st.getFreeBlocks()*st.getBlockSize());
    } 
    @LargeTest 
    public void testFreeApplicationCacheAllFiles() throws Exception { 
        boolean TRACKING = true;
        StatFs st = new StatFs("/data");
        long blks1 = getFreeStorageBlks(st);
        long availableMem = getFreeStorageSize(st);
        File cacheDir = mContext.getCacheDir();
        assertNotNull(cacheDir);
        createTestFiles1(cacheDir, "testtmpdir", 5);
        long blks2 = getFreeStorageBlks(st);
        if(localLOGV || TRACKING) Log.i(TAG, "blk1="+blks1+", blks2="+blks2);
        //this should free up the test files that were created earlier 
4
CodeRank

Related StatFs getFreeBlocks Questions & Answers:

getFreeBlocks Method Overview
This method was deprecated in API level 18. Use getFreeBlocksLong() instead.
See Code Examples for other Android StatFs Methods: