How to get the internal and external sdcard path in android

前端 未结 8 545
北恋
北恋 2020-12-09 09:23

Most of the new android devices have an internal sdcard and an external sdcard. I want to make a file explorer app but I can\'t find out how to get the path to use in my app

8条回答
  •  再見小時候
    2020-12-09 10:20

    File main=new File(String.valueOf(Environment.getExternalStorageDirectory().getAbsolutePath()));
    File[]t=main.getParentFile().listFiles();
    
    for(File dir:t)
    {
        Log.e("Main",dir.getAbsolutePath());
    }
    

    Output:

    E/Main: /storage/sdcard1
    E/Main: /storage/sdcard0
    

    I have one SD card and inbuilt memory.

提交回复
热议问题