code: private static boolean makeSureExists(File dir) {
          // Make sure the dest directories exist.
          if (!dir.exists()) {
              if (!dir.mkdirs()) {
                  Log.error("Could not create the directory "+dir.getPath());
                  return false;
              }
          }
          return true;
      }
docs: Make sure directory exist, create it if not.