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

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

    I did the following to get acces to all the external sd cards.

    With:

    File primaryExtSd=Environment.getExternalStorageDirectory();
    

    you get the path to the primary external SD Then with:

    File parentDir=new File(primaryExtSd.getParent());
    

    you get the parent dir of the primary external storage, and it is also the parent of all the external sd. Now, you can list all the storage and select the one that you want.

    Hope it is usefull.

提交回复
热议问题