code: protected static Long getTotalExternalStorage() {
          try {
              if (isExternalStorageMounted()) {
                  File path = Environment.getExternalStorageDirectory();
                  StatFs stat = new StatFs(path.getPath());
                  long blockSize = stat.getBlockSize();
                  long totalBlocks = stat.getBlockCount();
                  return totalBlocks * blockSize;
              }
          } catch (Exception e) {
              Log.e(TAG, "Error getting total external storage amount.", e);
          }
  
          return null;
      }
docs: Get the total amount of external storage, in bytes, or null if no external storage
  is mounted.
  
  @return the total amount of external storage, in bytes, or null if no external storage
  is mounted