Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a036b927 authored by tibbi's avatar tibbi
Browse files

add an extra way of detecting an SD card

parent 991cc94f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '3.13.4'
        propVersionName = '3.13.6'
        kotlin_version = '1.2.21'
        support_libs = '27.0.2'
    }
+12 −0
Original line number Diff line number Diff line
@@ -35,6 +35,18 @@ fun Context.getSDCardPath(): String {
        sdCardPath = directories.firstOrNull() ?: ""
    }

    if (sdCardPath.isEmpty()) {
        val SDpattern = Pattern.compile("^[A-Za-z0-9]{4}-[A-Za-z0-9]{4}$")
        try {
            File("/storage").listFiles()?.forEach {
                if (SDpattern.matcher(it.name).matches()) {
                    sdCardPath = "/storage/${it.name}"
                }
            }
        } catch (e: Exception) {
        }
    }

    return sdCardPath.trimEnd('/')
}