Obteniendo canciones de Android desde la tarjeta SD
Estoy recuperando mis canciones de la tarjeta SD y lo coloco en la vista de lista.
Estoy usando este método. pero está tomando algún tiempo y si la ruta es diferente no obtuve esos datos.
asi que ,WHAT ¿Hay algún script útil que muestre canciones de todas mis tarjetas SD? Si están en el directorio / canciones.
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"));
}
}
Por favor haga sus comentarios sobre esto.