Reputation: 912
I have created an ArrayList to scan .mp3 files from external storage:
final ArrayList<File> myplaylist0 = findSongs0(Environment.getExternalStorageDirectory());
Function findsongs0 is shown below:
public ArrayList<File> findSongs0(File root){
ArrayList<File> al=new ArrayList<File>();
File[] files = root.listFiles();
for(File singleFile : files){
if(singleFile.isDirectory() && !singleFile.isHidden()){
al.addAll(findSongs(singleFile));
}
else
{
if(singleFile.getName().endsWith(".mp3") || singleFile.getName().endsWith(".wav")){
al.add(singleFile);
}
}
}
return al;
}
The above codes give me list of all .mp3 files from my phone storage.
Now, my question is, how to scan mp3 files from the particular folder instead of whole storage. What should I modify in the above code??
Upvotes: 0
Views: 359
Reputation: 4791
Your argument should be like
new File(Environment.getExternalStorageDirectory()+"/"+"<your_mp3_folder>")
i.e
File myfile=new File(Environment.getExternalStorageDirectory()+"/"+"<your_mp3_folder>")
final ArrayList<File> myplaylist0 = findSongs0(myfile);
Upvotes: 1