I am trying to delete a video file located at the path
/storage/6638-3139/DCIM/Camera/20180503_144303.mp4
I have done below code for that.
delete(getContext(),file);
public static boolean delete(final Context context, final File file)
{
final String where = MediaStore.MediaColumns.DATA + "=?";
final String[] selectionArgs = new String[] {
file.getAbsolutePath()
};
final ContentResolver contentResolver = context.getContentResolver();
final Uri filesUri = MediaStore.Files.getContentUri("external");
contentResolver.delete(filesUri, where, selectionArgs);
if (file.exists()) {
contentResolver.delete(filesUri, where, selectionArgs);
}
return !file.exists();
}
When i am using above code then the video i couldn't see them in my gallery but when i am exploring my file manager its exist.
file.delete()
- This method is also not working.
I am using the same path.
When i am saving this video file in internal memory and then trying to delete from there then that time its working fine but in case of sd card its not working.
Please help.