aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/github/daneren2005/dsub/util/FileUtil.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java
index 8bd53c0c..b9d7fd1b 100644
--- a/src/github/daneren2005/dsub/util/FileUtil.java
+++ b/src/github/daneren2005/dsub/util/FileUtil.java
@@ -442,6 +442,24 @@ public class FileUtil {
if (!DEFAULT_MUSIC_DIR.exists() && !DEFAULT_MUSIC_DIR.mkdirs()) {
Log.e(TAG, "Failed to create default dir " + DEFAULT_MUSIC_DIR);
+
+ // Some devices seem to have screwed up the new media directory API. Go figure. Try again with standard locations
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ dirs = ContextCompat.getExternalFilesDirs(context, null);
+
+ for(int i = dirs.length - 1; i >= 0; i--) {
+ DEFAULT_MUSIC_DIR = new File(dirs[i], "music");
+ if(dirs[i] != null) {
+ break;
+ }
+ }
+
+ if (!DEFAULT_MUSIC_DIR.exists() && !DEFAULT_MUSIC_DIR.mkdirs()) {
+ Log.e(TAG, "Failed to create default dir " + DEFAULT_MUSIC_DIR);
+ } else {
+ Log.w(TAG, "Stupid OEM's messed up media dir API added in 5.0");
+ }
+ }
}
}