How to get the internal and external sdcard path in android

前端 未结 8 520
北恋
北恋 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:19

    but there is another path for the other external sdcard like /storage1 or /storage2

    There is nothing in the Android SDK -- at least through Android 4.1 -- that gives you access to those paths. They may not be readable or writable by your app, anyway. The behavior of such storage locations, and what they are used for, is up to device manufacturers.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题