Control the storage of photos taken with the camera of the device

0

I am trying to use the camera of my device to take a photo but I see that the image is stored in 2 locations, this is my code:

private void takePhoto() {
    nombreFoto();
    Intent intent = new    Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File file = new File(Environment.getExternalStorageDirectory().toString() + File.separator + "Pictures/imagen.jpg");
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
    intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    startActivityForResult(intent, 300);
}

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 300) {
        File file = new File(Environment.getExternalStorageDirectory().toString() + File.separator + "Pictures/UnkShopp.jpg");
        bitmap = Methods.decodeSampledBitmapFromFile(file.getAbsolutePath(), 1000, 700);
        ivFoto.setImageBitmap(bitmap);   
   }
}

This works fine, it stores the image in the defined folder and with the name I gave it, the problem is that I see that it is also stored in the DCIM / Camera folder of the internal storage and with a specific name.

How can I avoid that? I would like some solutions, maybe get the name of that image and then delete it, or maybe block the permission so that it is not stored in the internal memory.

I know it's a little complicated since you're using another camera application, what could I do? Thank you!

    
asked by Luis Yul 19.08.2018 в 21:22
source

0 answers