Commit 521bb140 authored by Sébastien Toque's avatar Sébastien Toque
Browse files

Do not keep folders which are not under the root folder

parent 6f01cc95
......@@ -504,6 +504,15 @@ public class DatabaseManager {
mDb.delete(DIR_TABLE_NAME, DIR_ROW_PATH + "=?", new String[] { path });
}
/**
* 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
......
......@@ -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));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment