[Android] New function for recursive deletion of directories
Geoffrey Métais
git at videolan.org
Wed Feb 18 16:07:46 CET 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 18 16:00:40 2015 +0100| [5fb418e07268ad1fd8e1463db6cb3ec954230ac8] | committer: Geoffrey Métais
New function for recursive deletion of directories
CID #1226286
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=5fb418e07268ad1fd8e1463db6cb3ec954230ac8
---
vlc-android/src/org/videolan/vlc/MediaDatabase.java | 16 +++++++++++++++-
.../src/org/videolan/vlc/gui/BrowserActivity.java | 9 +--------
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
index f396e0b..c87a805 100644
--- a/vlc-android/src/org/videolan/vlc/MediaDatabase.java
+++ b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
@@ -456,7 +456,7 @@ public class MediaDatabase {
PLAYLIST_MEDIA_ORDER + "=?",
new String[] { playlistName, Integer.toString(position) });
- playlistShiftItems(playlistName, position+1, -1);
+ playlistShiftItems(playlistName, position + 1, -1);
}
/**
@@ -850,6 +850,20 @@ public class MediaDatabase {
}
/**
+ * Delete all matching directories from directories table
+ *
+ * @param path
+ */
+ public synchronized void recursiveRemoveDir(String path) {
+ for(File f : getMediaDirs()) {
+ final String dirPath = f.getPath();
+ if(dirPath.startsWith(path))
+ mDb.delete(DIR_TABLE_NAME, DIR_ROW_PATH + "=?", new String[] { dirPath });
+ }
+
+ }
+
+ /**
*
* @return
*/
diff --git a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
index a9ec846..3a163ef 100644
--- a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
@@ -128,14 +128,7 @@ public class BrowserActivity extends ListActivity {
@Override
public boolean onMenuItemClick(MenuItem arg0) {
// remove any checkmarks of the custom item
- final MediaDatabase dbManager = MediaDatabase.getInstance();
- synchronized (dbManager) {
- for(File f : dbManager.getMediaDirs()) {
- final String path = f.getPath();
- if(path.startsWith(item.getPath()))
- dbManager.removeDir(path);
- }
- }
+ MediaDatabase.getInstance().recursiveRemoveDir(item.getPath());
CustomDirectories.removeCustomDirectory(item.getPath());
refresh();
return true;
More information about the Android
mailing list