how to get file path from sd card in android

后端 未结 7 1015
旧时难觅i
旧时难觅i 2020-11-28 09:00

hi all i have mp3 files in sd card. how to get file path of mp3 song from sd card.

please assist me.

7条回答
  •  广开言路
    2020-11-28 09:57

    this code helps to get it easily............

    Actually in some devices external sdcard default name is showing as extSdCard and for other it is sdcard1. This code snippet helps to find out that exact path and helps to retrive you the path of external device..

    String sdpath,sd1path,usbdiskpath,sd0path; 
    
    if(new File("/storage/extSdCard/").exists()) 
    { 
      sdpath="/storage/extSdCard/";
      Log.i("Sd Cardext Path",sdpath); 
    } 
    if(new File("/storage/sdcard1/").exists()) 
    { 
      sd1path="/storage/sdcard1/";
      Log.i("Sd Card1 Path",sd1path); 
    } 
    if(new File("/storage/usbcard1/").exists()) 
    { 
      usbdiskpath="/storage/usbcard1/";
      Log.i("USB Path",usbdiskpath); 
    } 
    if(new File("/storage/sdcard0/").exists()) 
    { 
      sd0path="/storage/sdcard0/";
      Log.i("Sd Card0 Path",sd0path); 
    }
    

提交回复
热议问题