title: List All Mp3 files in android
body: <p>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 files which i copied using adb). I also want it to list using Album, artist etc. please help in this.</p>
  
  <pre><code>final String MEDIA_PATH = Environment.getExternalStorageDirectory()+"";
  
  private ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
  // Constructor
  public SongsManager(){
  
  }
  
  /**
   * Function to read all mp3 files from sdcard
   * and store the details in ArrayList
   * */
  public ArrayList&lt;HashMap&lt;String, String&gt;&gt; getPlayList(){
      File home = new File(MEDIA_PATH);
  
      //if (home.listFiles(new FileExtensionFilter()).length &gt; 0) {
      if (home.listFiles(new FileExtensionFilter())!=null) {
  
          for (File file : home.listFiles(new FileExtensionFilter())) {
              HashMap&lt;String, String&gt; song = new HashMap&lt;String, String&gt;();
              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
   * */
  class FileExtensionFilter implements FilenameFilter {
      public boolean accept(File dir, String name) {
          return (name.endsWith(".mp3") || name.endsWith(".MP3"));
      }
  }
  </code></pre>