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

后端 未结 5 1883
日久生厌
日久生厌 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:41

     ArrayListnameList = new ArrayList();
     File yourDir = new File(Environment.getExternalStorageDirectory(), "/myFolder");
     for (File f : yourDir.listFiles()) 
     {
        if (f.isFile())
        {
           nameList.add(f.getName);
        }
    
    }
    

提交回复
热议问题