I am trying to delete an image from the Camera folder of phone (hardware) via app (programmatically). the code I am using is as follows
File file = new File(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryDcim), "/Camera");
var images = file.ListFiles();
var file2 = new File(file.AbsolutePath, "/myImage.jpg");
bool deleted = file2.Delete();
The AndroidManifest.xml has only following permissions
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
The path file2 showing is
"{/storage/emulated/0/DCIM/Camera/myImage.jpg}"
still it is not deleting the image from the mobile. However, when the above code executes first time then it shows that the image has been deleted i.e. deleted variable is true but when I check myImage.jpg in my mobile its still there.
In subsequent execution of the code, it doesn't get myImage.jpg in images variable but file present in the mobile Camera folder.
There is already an answer in java but I am using C# Xamarin.