Android examples for android.media:Video
delete Video File From Media Provider
import java.io.File; import java.util.ArrayList; import java.util.List; import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore.Video; import android.util.Log; public class Main { private static final String t = "MediaUtils"; public static final int deleteVideoFileFromMediaProvider(Context ctxt, String videoFile) { if (videoFile == null) return 0;// w w w.j a va2s .co m ContentResolver cr = ctxt.getContentResolver(); // video int count = 0; Cursor videoCursor = null; try { String select = Video.Media.DATA + "=?"; String[] selectArgs = { videoFile }; String[] projection = { Video.VideoColumns._ID }; videoCursor = cr.query(android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, select, selectArgs, null); if (videoCursor.getCount() > 0) { videoCursor.moveToFirst(); List<Uri> videoToDelete = new ArrayList<Uri>(); do { String id = videoCursor.getString(videoCursor.getColumnIndex(Video.VideoColumns._ID)); videoToDelete.add(Uri.withAppendedPath(android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI, id)); } while (videoCursor.moveToNext()); for (Uri uri : videoToDelete) { Log.i(t, "attempting to delete: " + uri); count += cr.delete(uri, null, null); } } } catch (Exception e) { Log.e(t, e.toString()); } finally { if (videoCursor != null) { videoCursor.close(); } } File f = new File(videoFile); if (f.exists()) { f.delete(); } return count; } }