[Android] Fix deleteFile Util method
Geoffrey Métais
git at videolan.org
Wed May 20 19:20:40 CEST 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed May 20 19:19:53 2015 +0200| [dba74527b68cda3aeaf3fbf20048742110d2ed66] | committer: Geoffrey Métais
Fix deleteFile Util method
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=dba74527b68cda3aeaf3fbf20048742110d2ed66
---
vlc-android/src/org/videolan/vlc/util/Util.java | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index 89bb58d..002e463 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -317,21 +317,17 @@ public class Util {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static boolean deleteFile (Context context, String path){
boolean deleted = false;
- if (path.startsWith("file://"))
- path = path.substring(5);
- else
- return deleted;
+ path = Uri.decode(Strings.removeFileProtocole(path));
+ //Delete from Android Medialib, for consistency with device MTP storing and other apps listing content:// media
if (LibVlcUtil.isHoneycombOrLater()){
ContentResolver cr = context.getContentResolver();
String[] selectionArgs = { path };
deleted = cr.delete(MediaStore.Files.getContentUri("external"),
- MediaStore.MediaColumns.DATA + "=?", selectionArgs) > 0;
- }
- if (!deleted){
- File file = new File(Uri.decode(path));
- if (file.exists())
- deleted = file.delete();
+ MediaStore.Files.FileColumns.DATA + "=?", selectionArgs) > 0;
}
+ File file = new File(path);
+ if (file.exists())
+ deleted |= file.delete();
return deleted;
}
More information about the Android
mailing list