I am creating an image in DCIM/Camera (default directory), after creating I am deleting the original filename and rename the newly created image to the deleted filename like
OriginalFileName- image04.jpg
NewFileName - image04(1).jpg
Deleting the OriginalFile, now the structure will look like this
OriginalFileName - //Deleted
NewFileName - image04.jpg
The above is working great but when I open gallery I saw a blank image with the name of image04(1).jpg
but in the file manager, it doesn't exists.
How do I refresh the gallery after doing the above stuff. Note: The blank image wasn't created when I do processing in Internal Storage, this only happens with external SD card storage (external memory card slot).
I am using Android Marshmallow, I found that in Lolipop doesn't create any blank image.
How to rectify that.
Edit:
I used ContentResolver.Delete(sourceURI, null, null);
but it throws exception.
sourceURI: {content://com.android.externalstorage.documents/tree/D660-18BD%3A/document/D660-18BD%3AAlbum%201%2F20180423_184057%20(1)%20(1).jpg}
Exception:
{Java.Lang.UnsupportedOperationException: Delete not supported
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualIntMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <e8c0e16a54534fa885244f0ad837c79e>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualInt32Method (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0001f] in <e8c0e16a54534fa885244f0ad837c79e>:0
at Android.Content.ContentResolver.Delete (Android.Net.Uri url, System.String where, System.String[] selectionArgs) [0x00068] in <e79c73bcbbb547688bef6c7e9665c95e>:0
at iPro.Droid.ResizePicActivity+<>c__DisplayClass35_0+<<StartProcessing>b__0>d.MoveNext () [0x00ddf] in H:\Android App\myapp\myapp.Android\ResizePicActivity.cs:583
--- End of managed Java.Lang.UnsupportedOperationException stack trace ---
java.lang.UnsupportedOperationException: Delete not supported
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.delete(ContentProviderNative.java:544)
at android.content.ContentResolver.delete(ContentResolver.java:1380)
}