I am fetching my songs from the SD card and putting him to the list view.
I am using this method. but its taking some time and if path is different I didn't get that data.
so , QUE Is there any helpfull script that display songs from all my sd card. If they are into directory/songs .
public ArrayList<HashMap<String, String>> getPlayList(){
File home = new File(MEDIA_PATH);
if (home.listFiles(new FileExtensionFilter()).length > 0) {
for (File file : home.listFiles(new FileExtensionFilter())) {
HashMap<String, String> song = new HashMap<String, String>();
song.put("songTitle", file.getName().substring(0, (file.getName().length() - 4)));
song.put("songPath", file.getPath());
// Adding each song to SongList
songsList.add(song);
}
}
// return songs list array
return songsList;
}
class FileExtensionFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
return (name.endsWith(".mp3") || name.endsWith(".MP3"));
}
}
Please give your comments on this .
this will help you to make a listview using that playlist
}
//try this its working code
I am getting cursor count 0 actually i added a folder to sdcard but files are not coming
I once used MediaStore for my music application, this is a very more efficient and correct way to retrieve data and then display it using a ListView. This will retrieve any music file stored in any folder on your SDCard.
please use this code to implement this functionality.
}
XML file code :