android get all external storage path for all devices

后端 未结 3 1530
后悔当初
后悔当初 2021-01-06 19:34

getExternalStorageDirectory() return SD card path on my phone. (Huawei Y320 - android 4.2.2).

now, how to get path Pho

3条回答
  •  -上瘾入骨i
    2021-01-06 20:14

    try this code to get all external storage path for all devices

    File[] f = ContextCompat.getExternalFilesDirs(getApplicationContext(),null);
    for (int i=0;i< f.length;i++)
    {
      String path = f[i].getParent().replace("/Android/data/","").replace(getPackageName(),"");
      Log.d("DIRS",path); //sdcard and internal and usb
    }
    

提交回复
热议问题