From 3f28cdaaa53cfcd592409f869f2e051704f90e06 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 1 Dec 2014 22:06:55 -0800 Subject: Use the new media dir API on 5.0+ --- src/github/daneren2005/dsub/util/FileUtil.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/github') diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java index 7afeec93..ac2c080b 100644 --- a/src/github/daneren2005/dsub/util/FileUtil.java +++ b/src/github/daneren2005/dsub/util/FileUtil.java @@ -403,7 +403,13 @@ public class FileUtil { public static File getDefaultMusicDirectory(Context context) { if(DEFAULT_MUSIC_DIR == null) { - File[] dirs = ContextCompat.getExternalFilesDirs(context, null); + File[] dirs; + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + dirs = context.getExternalMediaDirs(); + } else { + 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) { -- cgit v1.2.3