¡esta es la solución correcta para usted! o te doy un link por estas cosas!
public class SongsManager {
// SDCard Path
//choose your path for me i choose sdcard
final String MEDIA_PATH = new String("/sdcard/");
private ArrayList<hashmap<string, string="">> songsList = new ArrayList<hashmap<string, string="">>();
// Constructor
public SongsManager(){
}
/**
* Function to read all mp3 files from sdcard
* and store the details in ArrayList
* */
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 to filter files which are having .mp3 extension
* */
//you can choose the filter for me i put .mp3
class FileExtensionFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
return (name.endsWith(".mp3") || name.endsWith(".MP3"));
}
}
}
¿Qué has hecho hasta ahora? Stack Overflow no es un _I-have-a-problem-provide-code_-site. Nos muestras lo que has hecho y te decimos qué está mal. –
Por favor marque esta respuesta como una ref http://stackoverflow.com/questions/11285288/android-mediastore-get-distinct-folders-of-music-files/28473755#28473755 –