title: Throwing null pointer exception in Android
body: <p>I'm trying to fetch an audio file from the audio directory, for that I'm using below code. I'm not able to figure out why this condition <code>if (home.listFiles(new FileExtensionFilter()).length &gt; 0)</code> is throwing an error. Code is given below.</p>
  
  <pre><code>Uri allsongsuri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
  final String MEDIA_PATH = allsongsuri.toString();
  private ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
  public ArrayList&lt;HashMap&lt;String, String&gt;&gt; getPlayList(){
      System.out.println(" -- "+MEDIA_PATH);
      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 songsList;
  }
  
  class FileExtensionFilter implements FilenameFilter {
      public boolean accept(File dir, String name) {
      return (name.endsWith(".mp3") || name.endsWith(".MP3"));
  }
  </code></pre>
  
  <p>I need to store audio file in ArrayList using hashMap. I tried this example to store file in List
      <a href="http://android-er.blogspot.in/2012/02/list-audio-media-in-mediastoreaudiomedi.html" rel="nofollow">http://android-er.blogspot.in/2012/02/list-audio-media-in-mediastoreaudiomedi.html</a> . Using this example I tried a lot to store the list in ArrayList as my reqirement need that. But didn't succeed. 
      I need help. I have to store Audio file in Arraylist.</p>