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

前端 未结 26 3389
清歌不尽
清歌不尽 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条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 05:35

    I guess to use the external sdcard you need to use this:

    new File("/mnt/external_sd/")
    

    OR

    new File("/mnt/extSdCard/")
    

    in your case...

    in replace of Environment.getExternalStorageDirectory()

    Works for me. You should check whats in the directory mnt first and work from there..


    You should use some type of selection method to choose which sdcard to use:

    File storageDir = new File("/mnt/");
    if(storageDir.isDirectory()){
        String[] dirList = storageDir.list();
        //TODO some type of selecton method?
    }
    

提交回复
热议问题