Find location of a removable SD card

前端 未结 22 3207
南方客
南方客 2020-11-21 11:32

Is there an universal way to find the location of an external SD card?

Please, do not be confused with External Storage.

Environment.getExternalStorage

22条回答
  •  佛祖请我去吃肉
    2020-11-21 11:57

    By writing below code you will get the location:

    /storage/663D-554E/Android/data/app_package_name/files/

    which stores your app data at /android/data location inside the sd_card.

    File[] list = ContextCompat.getExternalFilesDirs(MainActivity.this, null);
    
    list[1]+"/fol" 
    

    for getting location pass 0 for internal and 1 for sdcard to file array.

    I have tested this code on a moto g4 plus and Samsung device (all works fine).

    hope this might helpful.

提交回复
热议问题