I'm saving an image in DCIM directory, but in cases, I need to delete it. Previously, I called just image.delete(), where image is file. But now this image is saved in another way:
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, name);
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "image/png");
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, "DCIM" + File.separator + IMAGES_FOLDER_NAME);
Uri imageUri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
OutputStream fos = resolver.openOutputStream(imageUri);
boolean saved = bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
I tried to make a query with its name and call contentResolver.delete(...), but it doesn't work.
I have permission to write external storage, but I don't want to use SAF.
How can I delete such file?