'How to save the image (taken using camera) manually in Android

I'd like to know how can I control when a pciture taken from camera can be saved, right now I have this code:

File storagePath = new File(Environment.
                    getExternalStorageDirectory() + "/PhotoAR/"); 
      storagePath.mkdirs(); 
   
      File myImage = new File(storagePath,
                    Long.toString(System.currentTimeMillis()) + ".jpg");
            
      try
      {
        FileOutputStream out = new FileOutputStream(myImage);
        newImage.compress(Bitmap.CompressFormat.JPEG, 80, out);


        out.flush();
        out.close();
      }
      catch(FileNotFoundException e)
      {
        Log.d("In Saving File", e + "");    
      }
      catch(IOException e)
      {
        Log.d("In Saving File", e + "");
      }

But right now, the preview isn't working, I mean, the image is saved in PhotoAR folder, but it's saved automatically, I'd like to have a button or something, and save or discard option, is there any way to improve it to accomplish this behavior?

Any example perhaps?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source