private File getSdcardDir(String type) {
    String externalStorage = System.getenv("EXTERNAL_STORAGE");

    if (externalStorage == null) {
      throw new RuntimeException(
          "No $EXTERNAL_STORAGE has been set on the device, please report this bug!");
    }

    String sdcardDirectory =
        mArguments.containsKey(SDCARD_DIRECTORY)
            ? mArguments.getString(SDCARD_DIRECTORY)
            : DEFAULT_SDCARD_DIRECTORY;

    String parent =
        String.format("%s/%s/%s/", externalStorage, sdcardDirectory, mContext.getPackageName());

    String child = String.format("%s/screenshots-%s", parent, type);

    new File(parent).mkdirs();

    File dir = new File(child);
    dir.mkdir();

    if (!dir.exists()) {
      throw new RuntimeException(
          "Failed to create the directory "
              + dir.getAbsolutePath()
              + " for screenshots. Is your sdcard directory read-only?");
    }

    setWorldWriteable(dir);
    return dir;
  }
Provides a directory for an Album to store its screenshots in.
core/src/main/java/com/facebook/testing/screenshot/internal/ScreenshotDirectories.java