Last active
October 10, 2019 21:03
-
-
Save juliancadi/31dd81d8600e9d405ccb6ca4f3c6adcd to your computer and use it in GitHub Desktop.
External storage path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val externalStoragePath: String? | |
@RequiresApi(Build.VERSION_CODES.O) | |
get() { | |
val externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null) | |
if (externalFilesDirs.size == 1 && Environment.isExternalStorageEmulated()) { return null } | |
return externalFilesDirs.filterNotNull().firstOrNull { file -> | |
Environment.MEDIA_MOUNTED == EnvironmentCompat.getStorageState(file) && | |
!file.path.contains(Environment.getExternalStorageDirectory().path) | |
}?.path.also { logger.debug("External memory path $it") } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment