How can I get the external SD card path for Android 4.0+?

前端 未结 26 3204
清歌不尽
清歌不尽 2020-11-22 04:48

Samsung Galaxy S3 has an external SD card slot, which is mounted to /mnt/extSdCard.

How can I get this path by something like Environment.getExter

26条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 05:45

    You can use something like - Context.getExternalCacheDirs() or Context.getExternalFilesDirs() or Context.getObbDirs(). They give application specific directories in all external storage devices where the application can store its files.

    So something like this - Context.getExternalCacheDirs()[i].getParentFile().getParentFile().getParentFile().getParent() can get you the root path of external storage devices.

    I know these commands are for a different purpose but other answers didn't work for me.

    This link gave me good pointers - https://possiblemobile.com/2014/03/android-external-storage/

提交回复
热议问题