@Test public void testDeleteMedia() throws Exception { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return; } final File file = configurator.createTestFileMedia(); final long id = configurator.insertToMediaStoreAsMedia(file); try { getMediaManager().deleteMedia(id); assertFalse(configurator.existsInMediaStore( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id)); } finally { configurator.cleanup(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, file, id); } }
@Override public void deleteMedia(final long id) throws IOException { final int count = contentResolver.delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, MediaStore.Audio.Media._ID + '=' + id, null); if (count != 1) { throw new IOException( "Unexpected count when deleting playlist from MediaStore, count = " + count); } }
MediaManagerMediaStore implements MediaManager { @Override public void deleteMedia(final long id) throws IOException { final int count = contentResolver.delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, MediaStore.Audio.Media._ID + '=' + id, null); if (count != 1) { throw new IOException( "Unexpected count when deleting playlist from MediaStore, count = " + count); } } }
MediaManagerMediaStore implements MediaManager { @Override public void deleteMedia(final long id) throws IOException { final int count = contentResolver.delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, MediaStore.Audio.Media._ID + '=' + id, null); if (count != 1) { throw new IOException( "Unexpected count when deleting playlist from MediaStore, count = " + count); } } MediaManagerMediaStore(
            @NonNull final ContentResolver contentResolver,
            @NonNull final AlbumMediaIdsProvider albumMediaIdsProvider); }
MediaManagerMediaStore implements MediaManager { @Override public void deleteMedia(final long id) throws IOException { final int count = contentResolver.delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, MediaStore.Audio.Media._ID + '=' + id, null); if (count != 1) { throw new IOException( "Unexpected count when deleting playlist from MediaStore, count = " + count); } } MediaManagerMediaStore(
            @NonNull final ContentResolver contentResolver,
            @NonNull final AlbumMediaIdsProvider albumMediaIdsProvider); @Override void deletePlaylist(final long id); @Override void deleteMedia(final long id); @Override void deleteAlbum(final long id); }
MediaManagerMediaStore implements MediaManager { @Override public void deleteMedia(final long id) throws IOException { final int count = contentResolver.delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, MediaStore.Audio.Media._ID + '=' + id, null); if (count != 1) { throw new IOException( "Unexpected count when deleting playlist from MediaStore, count = " + count); } } MediaManagerMediaStore(
            @NonNull final ContentResolver contentResolver,
            @NonNull final AlbumMediaIdsProvider albumMediaIdsProvider); @Override void deletePlaylist(final long id); @Override void deleteMedia(final long id); @Override void deleteAlbum(final long id);  }