how to get the file names stored in sd card in android

后端 未结 5 1934
日久生厌
日久生厌 2021-02-02 00:52


i have a folder in sd card which contains several files. now i need to get the names of that files. can anybody have any idea how to get the file names stored in s

5条回答
  •  渐次进展
    2021-02-02 01:27

    If you want to retrieve all files and folder from a specific path of FOLDER then use this code it will help you

    String path="/mnt/sdcard/dcim";  //lets its your path to a FOLDER
    
    String root_sd = Environment.getExternalStorageDirectory().toString();
    File file = new File(path) ;       
    File list[] = file.listFiles();
      for(File f:list)
        {
           filename.add(f.getName());//add new files name in the list
         }              
    

提交回复
热议问题