-1

I am storing an image in internal storage. I have a bitmap. but it is also storing a copy of that image in pictures folder named with the time stamp. please help me on that.

 private void saveBitmapCropped(Bitmap bitmap,String uid){
    String path = Environment.getExternalStorageDirectory().toString();
    File file=new File(path+"/.Cropped_images",uid+".jpg");
    OutputStream fOut = null;
    saveRes(String.valueOf(Uri.fromFile(file)),"uri");
    try {
        fOut = new FileOutputStream(file);
        Bitmap pictureBitmap = bitmap;
        pictureBitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut); // saving the Bitmap to a file compressed as a JPEG with 85% compression rate
        fOut.flush();
        fOut.close();
        MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Fawad Khan
  • 103
  • 2
  • 12
  • I'm not clear on what is the behaviour you're seeing vs what is the behaviour you're expecting to see. Can you clarify? – Malcolm Crum Sep 08 '19 at 09:03
  • If the image came from `ACTION_IMAGE_CAPTURE`, then the camera app decided to save its own copy of the image. That is well within the rights of the developers of that camera app. – CommonsWare Sep 08 '19 at 10:57

1 Answers1

0

I identify the issue, only the issue was with this line.. if you delete this line all the things goes well

 MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
Fawad Khan
  • 103
  • 2
  • 12