code: public static boolean saveBitmapAsPNG(String filename, Bitmap bitmap) {
          FileOutputStream outStream = null;
          try {
              outStream = new FileOutputStream(filename);
              bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
          } catch (Exception e) {
              e.printStackTrace();
              return false;
          } finally {
              try {
                  if (outStream != null) {
                      outStream.close();
                  }
              } catch (IOException e) {
                  e.printStackTrace();
                  return false;
              }
          }
  
          return true;
      }
docs: Saves a {@code Bitmap} as a PNG file.
  
  @param filename The file path on the file system.
  @param bitmap The input {@code Bitmap} object.
  @return {@code true} if successful.