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
Try This
String path;
File sdCardRoot = Environment.getExternalStorageDirectory();
File dir = new File(sdCardRoot.getAbsolutePath() + "/yourDirectory/");
if (dir.exists()) {
if (dir.listFiles() != null) {
for (File f : dir.listFiles()) {
if (f.isFile())
path = f.getName();
if (path.contains(".mp3")) {
yourArrayList.add(path);
}
}
}
}