Code example for StatFs

Methods: getBlockSizegetFreeBlocks

		// Make sure that there's sufficient space 
		//File baseDir = Environment.getExternalStorageDirectory(); 
		File baseDir = context.getFilesDir();	
		StatFs spaceData = new StatFs( baseDir.getAbsolutePath() );
		//long totalBytes = (long) spaceData.getBlockCount() * (long) spaceData.getBlockSize(); 
		long freeBytes =  (long) spaceData.getFreeBlocks() * (long) spaceData.getBlockSize();
		if (freeBytes < fileSize + 2048)
			throw new InsufficientSpaceException(); 
		//File appDir = new File(baseDir, "/Android/data/" + apkInfo.getPackageName() + "/cache/"); 
		if (baseDir.canWrite() == false)
			throw new FlashDriveUnavailable(); 
Stop searching for code, let great code find you!  Add Codota to your java IDE