[Android] Do not keep folders which are not under the root folder
Sébastien Toque
git at videolan.org
Thu Aug 30 20:25:24 CEST 2012
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Thu Aug 30 19:45:30 2012 +0200| [521bb140eaf38f3e6526581a591dd20f8f4c3d3f] | committer: Sébastien Toque
Do not keep folders which are not under the root folder
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=521bb140eaf38f3e6526581a591dd20f8f4c3d3f
---
vlc-android/src/org/videolan/vlc/DatabaseManager.java | 9 +++++++++
vlc-android/src/org/videolan/vlc/MediaLibrary.java | 3 +++
2 files changed, 12 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/DatabaseManager.java b/vlc-android/src/org/videolan/vlc/DatabaseManager.java
index 2ba06b2..e831aca 100644
--- a/vlc-android/src/org/videolan/vlc/DatabaseManager.java
+++ b/vlc-android/src/org/videolan/vlc/DatabaseManager.java
@@ -505,6 +505,15 @@ public class DatabaseManager {
}
/**
+ * Delete directory from directories table if not under root folder
+ *
+ * @param path
+ */
+ public synchronized void removeDirNotUnder(String root) {
+ mDb.delete(DIR_TABLE_NAME, DIR_ROW_PATH + " NOT LIKE ?", new String[] { root+"%" });
+ }
+
+ /**
*
* @return
*/
diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index f83784f..2286e8b 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -169,12 +169,15 @@ public class MediaLibrary {
// use the external storage as our default root directory (most often /mnt/sdcard)
if (root == null) {
root = Environment.getExternalStorageDirectory().getAbsolutePath();
+ } else {
+ root = new File(root).getAbsolutePath();
}
// show progressbar in footer
MainActivity.showProgressBar(mContext);
// get directories from database
+ mDBManager.removeDirNotUnder(root);
directories.addAll(mDBManager.getMediaDirs());
if (directories.isEmpty())
directories.add(new File(root));
More information about the Android
mailing list