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

前端 未结 26 2698
清歌不尽
清歌不尽 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:47

    that's not true. /mnt/sdcard/external_sd can exist even if the SD card is not mounted. your application will crash when you try to write to /mnt/sdcard/external_sd when it's not mounted.

    you need to check if the SD card is mounted first using:

    boolean isSDPresent = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    

提交回复
热议问题