code: private String getFilename(String filename, File file) {
          if (!file.exists()) {
              file.mkdirs();
          }
          String ext = ".jpg";
          //get extension
          /*if (Pattern.matches("^[.][p][n][g]", filename)){
              ext = ".png";
          }*/
  
          return (file.getAbsolutePath() + "/IMG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ext);
  
      }
docs: Get the file path of the compressed file
  
  @param filename
  @param file     Destination directory
  @return