[Android] Remove files from device MediaLib on deletion

Geoffrey Métais git at videolan.org
Tue Jan 6 18:10:41 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan  6 18:08:19 2015 +0100| [e0564a162935ed432e6c98e49c56fed22436cd72] | committer: Geoffrey Métais

Remove files from device MediaLib on deletion

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=e0564a162935ed432e6c98e49c56fed22436cd72
---

 vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java b/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
index 6f6466b..6ececbf 100644
--- a/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
+++ b/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
@@ -59,22 +59,16 @@ public class CommonDialogs {
     public static AlertDialog deleteMedia(final Context context,
                                           final String addressMedia,
                                           final VLCRunnable runnable) {
-        URI adressMediaUri = null;
-        try {
-            adressMediaUri = new URI (addressMedia);
-        } catch (URISyntaxException e) {
-            e.printStackTrace();
-        }
-        final File fileMedia = new File(adressMediaUri);
+        final String name = Uri.decode(addressMedia.substring(addressMedia.lastIndexOf('/')+1));
 
         return confirmDialog(
                 context,
                 context.getResources().getString(R.string.confirm_delete,
-                        fileMedia.getName()),
+                        name),
                 new DialogInterface.OnClickListener() {
                     @Override
                     public void onClick(DialogInterface dialog, int whichButton) {
-                        fileMedia.delete();
+                        Util.deleteFile(context, addressMedia);
                         if (runnable != null)
                             runnable.run();
                     }



More information about the Android mailing list