try fetching SD card path on Android 4.x too

This commit is contained in:
tibbi 2017-10-05 21:16:13 +02:00
parent fb30d04a6e
commit 4de01e4baa

View file

@ -23,10 +23,6 @@ import java.util.regex.Pattern
// http://stackoverflow.com/a/40582634/1967672
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
fun Context.getSDCardPath(): String {
if (!isLollipopPlus()) {
return ""
}
val directories = getStorageDirectories().filter { it.trimEnd('/') != getInternalStoragePath() }
val sdCardPath = directories.firstOrNull { !physicalPaths.contains(it.toLowerCase().trimEnd('/')) } ?: directories.firstOrNull() ?: ""
return sdCardPath.trimEnd('/')