title: NullPointerException:Attempt toget length of null array
body: <p>i need to create playlist from sdcard when i run my application it generate null pointer exception attempt get length of null array.  because it could not read file from sdcard. But i have song files in emulator sdcard folder.Here is the code i have tried but it not work please help me to fix the problem.</p>
  
  <pre><code>class Mp3Filter implements FilenameFilter{
       public boolean accept(File dir,String name) {
          return (name.endsWith(".mp3")); 
        }
  }
  public class Audio extends ListActivity{
  private MediaPlayer mp=new MediaPlayer();
  private final String SD_PATH=new String("/sdcard/");
  private List&lt;String&gt; songs=new ArrayList&lt;String&gt;();
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.audio);
      updatePlaylist();
      Button stpbtn =(Button) findViewById(R.id.stpbtn);
  
      stpbtn.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              mp.stop();
              mp.release();
          }
      });
  }
  private void updatePlaylist()
  {
      try
      {
           File home = new File (SD_PATH);
          if(home.listFiles(new Mp3Filter()).length &gt; 0)
          {
              for(File file:home.listFiles(new Mp3Filter()))
              {
                  songs.add(file.getName());
              }
              ArrayAdapter&lt;String&gt; songList = new ArrayAdapter&lt;String&gt;(Audio.this,R.layout.song_item,songs);
              setListAdapter(songList);
          }
      }
      catch(Exception e)
      {
          e.printStackTrace();
      }
    }
  }
  </code></pre>
  
  <p>here is my audio.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  
  &lt;ListView
      android:id="@+id/android:list"
      android:layout_width="match_parent"
      android:layout_height="401dp" &gt;
  &lt;/ListView&gt;
  
  &lt;Button
      android:id="@+id/stpbtn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/stpbtn" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>here is song_item.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TextView android:id="@+id/text1"    xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" /&gt;
  </code></pre>