@ SuppressWarnings ( "deprecation" ) @ TargetApi ( Build . VERSION_CODES . GINGERBREAD ) public static long getUsableSpace ( File path ) { if ( path == null ) { return - 1 ; } if ( Version . hasGingerbread ( ) ) { return path . getUsableSpace ( ) ; } else { if ( ! path . exists ( ) ) { return 0 ; } else { final StatFs stats = new StatFs ( path . getPath ( ) ) ; return ( long ) stats . getBlockSize ( ) * ( long ) stats . getAvailableBlocks ( ) ; } } }
Check how much usable space is available at a given path .