title: I'm starting to repeat MediaPlayer of mp3 music files but it is experiencing a music scan
body: <p>I am trying to create a media play MP3 player but it is making a mistake error causing the app to stop
  This is code MainActivity</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      ListView lv;
      String[] items;
      Button btnA1;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          btnA1 = (Button) findViewById(R.id.btnA);
          btnA1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent a1 = new Intent(getApplicationContext(), Player.class);
                  startActivity(a1);
                  finish();
              }
          });
          lv = (ListView) findViewById(R.id.lvPlaylist);
          final ArrayList&lt;File&gt; mySongs = findSongs(Environment.getExternalStorageDirectory());
          items = new String[mySongs.size()];
          for (int i = 0; i &lt; mySongs.size(); i++) {
              items[i] = mySongs.get(i).getName().toString().replace(".mp3", "").replace(".wav", "");
          }
  
          ArrayAdapter&lt;String&gt; adp = new ArrayAdapter&lt;String&gt;(getApplicationContext(), R.layout.song_layout,
                  R.id.textView, items);
          lv.setAdapter(adp);
          lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long l) {
                  startActivity(new Intent(getApplicationContext(), Player.class).putExtra("pos", position)
                          .putExtra("songlist", mySongs));
              }
          });
      }
  
      public ArrayList&lt;File&gt; findSongs(File root) {
          ArrayList&lt;File&gt; al = new ArrayList&lt;File&gt;();
          File[] files = root.listFiles();
          for (File singleFile : files) {
              if (singleFile.isDirectory() &amp;&amp; !singleFile.isHidden()) {
                  al.addAll(findSongs(singleFile));
              } else {
                  if (singleFile.getName().endsWith(".mp3") || singleFile.getName().endsWith(".wav")) {
                      al.add(singleFile);
                  }
              }
          }
          return al;
      }
  
      @Override
      public void onBackPressed() {
          AlertDialog.Builder ab = new AlertDialog.Builder(MainActivity.this);
          ab.setTitle("Exit");
          ab.setMessage("Are You Sure Exit?");
          ab.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                  android.os.Process.killProcess(android.os.Process.myPid());
                  System.exit(1);
                  MainActivity.this.finish();
              }
          });
  
          ab.setNegativeButton("No", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
              }
          });
          ab.show();
      }
  }
  </code></pre>
  
  <p>The error lies in </p>
  
  <pre><code>public ArrayList&lt;File&gt; findSongs(File root) {
      ArrayList&lt;File&gt; al = new ArrayList&lt;File&gt;();
      File[] files = root.listFiles();
      for (File singleFile : files) {
          if (singleFile.isDirectory() &amp;&amp; !singleFile.isHidden()) {
              al.addAll(findSongs(singleFile));
          } else {
              if (singleFile.getName().endsWith(".mp3") || singleFile.getName().endsWith(".wav")) {
                  al.add(singleFile);
              }
          }
      }
      return al;
  } 
  </code></pre>
  
  <p>If I replace <code>if (singleFile.isDirectory() &amp;&amp; !singleFile.isHidden()) {
                  al.addAll(findSongs(singleFile));</code>
  to <code>if (singleFile.isDirectory() &amp;&amp; singleFile.isHidden()) {
                  al.addAll(findSongs(singleFile));</code> then the app will only load the mp3 files on the sdcard deeper as sdcard / music does not</p>
  
  <p>If I'm horrible In singleFile, the app will be stopped</p>