diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-05-01 20:25:40 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-05-01 20:25:40 -0700 |
commit | 4e68c34f3e5edef90d4754c3ac4fe2590b2e5522 (patch) | |
tree | 99e019ff039577aa9e72f3b3208bcc9b63582a96 /src | |
parent | e2c1eb7313ecebc3b9de296c40f6bd85e3aada76 (diff) | |
download | dsub-4e68c34f3e5edef90d4754c3ac4fe2590b2e5522.tar.gz dsub-4e68c34f3e5edef90d4754c3ac4fe2590b2e5522.tar.bz2 dsub-4e68c34f3e5edef90d4754c3ac4fe2590b2e5522.zip |
Fix for devices with empty SD card slots
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/util/FileUtil.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java index e8516aa4..657ca50c 100644 --- a/src/github/daneren2005/dsub/util/FileUtil.java +++ b/src/github/daneren2005/dsub/util/FileUtil.java @@ -315,7 +315,13 @@ public class FileUtil { public static File getDefaultMusicDirectory(Context context) { if(DEFAULT_MUSIC_DIR == null) { File[] dirs = ContextCompat.getExternalFilesDirs(context, null); - DEFAULT_MUSIC_DIR = new File(dirs[dirs.length - 1], "music"); + 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); } |