code: @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();
              }
          }
      }
docs: Check how much usable space is available at a given path.
  
  @param path The path to check
  @return The space available in bytes by user, not by root, -1 means path is null, 0 means path is not exist.