Code example for StatFs

Methods: getBlockSize, getFreeBlocks

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