I am developing music player in android but stuck in reading MP3 files. here is my code to read all mp3 files. but its not returing any files from device(although there are some
File[] files=new File(YOUR_DIR).listFiles();
MediaMetadataRetriever mmr=new MediaMetadataRetriever();
for (File file:files)
{
String fname=file.getName();
String fpath=file.getAbsolutePath();
if (file.isFile() && fname.contains("."))
{
String ext=fname.substring(fname.lastIndexOf("."));
if (ext.equals(".mp3") || ext.equals(".MP3"))
{
mmr.setDataSource(fpath);
String title=mmr.extractMetadata(7);
String artist=mmr.extractMetadata(2);
String genre=mmr.extractMetadata(6);
String album=mmr.extractMetadata(1);
}
}
}
mmr.release();