I would like to remove a video that has been previously recorded using an Intent:
Intent captureVideoIntent = new Intent(
android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(captureVideoIntent, VIDEO_CAPTURED);
The method onActivityResult() get the recorded video as Intent data. I try to obtain the recorded file and delete it.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Code for modify and copy the video
try {
Uri androidUri = data.getData();
File file = new File(new java.net.URI(androidUri.toString()));
file.delete();
} catch (Exception e) {
e.printStackTrace();
}
}
But I get the error:
java.lang.IllegalArgumentException: Expected file scheme in URI: content://media/external/video/media/177.
Does somebody know how can I get the path of the recorded video and move or delete it?
This answer has how to get the path from a content URI. You should be able to pass its result to the
File
constructor.