1

I am trying to get the mount points for all storage (local and external).

This worked great until I went to 4.3:

Find an external SD card location

I know these mounts can be read only but that is ok. I also know that the mounts can still be discovered in 4.3+ because ES File Explorer app can find the mount points.

Community
  • 1
  • 1
lostintranslation
  • 23,756
  • 50
  • 159
  • 262

1 Answers1

0

Make sure you have permissions to at least read from external storage then try this:

Kotlin:

fun getExternalRootFolders(): List<File> {
    return context.getExternalFilesDirs(null)
            .filter { canUseExternalPath(it) }
            .map { File(it.toString().substringBefore("/Android")) }
}

private fun canUseExternalPath(path: File?): Boolean {
    return path?.let { Environment.MEDIA_MOUNTED == EnvironmentCompat.getStorageState(path) } == true
}
hal
  • 21
  • 2