title: how to get all all audio files from sd card android
body: <p>I want to write a class which gets all the mp3 files from the whole sd card. But actually it only gets the audio files laying directly on the sd card. so it doesnt search trough sub folders.I'd like to use Mediastore but i dont get it to an arraylist. Maybe you can help me, thanks a lot and sorry for beeing a noob ;) vinzenz</p>
  
  <pre><code>import java.io.File;
  import java.io.FilenameFilter;
  import java.util.ArrayList;
  import java.util.HashMap;
  
  import de.me.musicplayer.SongsManager.FileExtensionFilter;
  
  import android.database.Cursor;
  import android.net.Uri;
  import android.provider.MediaStore;
  
  
  
  
  public class SongsManager {
  
  final String MEDIA_PATH = new String("/sdcard/");
  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) {
          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>