Code example for StatFs

Methods: getBlockSize, getFreeBlocks, restat

0
        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 
        invokePMFreeApplicationCache(availableMem);