Code example for StatFs

Methods: getFreeBlocks, restat

0
    void failStr(Exception e) {
        Log.w(TAG, "e.getMessage="+e.getMessage());
        Log.w(TAG, "e="+e);
    } 
    long getFreeStorageBlks(StatFs st) {
        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);