I take my picture with the following code and create a tempFile in my app (external) folder 'MyFolder':
fun createFile(): File {
val imageName:String = "aaaa"
val temp: File = Environment.getExternalStorageDirectory()
val storageDir: File = File(temp,"MyFolder")
if (!storageDir.exists()) storageDir.mkdir()
val image:File = File.createTempFile(
imageName,".jpg", storageDir)
return image
}
Once it is taken, I optimise it and save it internally. Then I delete the image in 'MyFolder' using following code:
fun delete(imagePath: String) {
val file = File(imagePath)
if(file.exists()) file.delete()
}
When I finish, I see no image in 'MyFolder' which is what I expect as well BUT my image still shows publically in the DCIM folder. Can someone help me figuring out why this is happening? (I know I can create temp image in internal folder as well, but it is another issue for another question as I get errors with FileProvider getUri method)