code: public static long getDirSize(String path) {
          StatFs stat;
          try {
              stat = new StatFs(path);
          } catch (Exception e) {
              return 0;
          }
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
              return stat.getBlockSizeLong() * stat.getAvailableBlocksLong();
          } else {
              return (long)stat.getBlockSize() * (long)stat.getAvailableBlocks();
          }
      }
docs: Access to a directory available size.
  
  @param path path.
  
  @return space size.