title: Extracting the audio from a device and display it in a listview fails
body: <p>I want to display all the audio device of a device in a list view. The app throws an exception on opening. <strong>All the catch statements are being executed</strong></p>
  
  <p><strong>LogCat Messages</strong></p>
  
  <pre><code>07-31 22:58:46.131 3100-3100/prakhar.mediacontentprovider E/libprocessgroup: failed to make and chown /acct/uid_10058: Read-only file system
  07-31 22:58:46.131 3100-3100/prakhar.mediacontentprovider W/Zygote: createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
  07-31 22:58:46.131 3100-3100/prakhar.mediacontentprovider I/art: Not late-enabling -Xcheck:jni (already on)
  07-31 22:58:46.195 3100-3108/prakhar.mediacontentprovider I/art: Debugger is no longer active
  07-31 22:58:46.307 3100-3100/prakhar.mediacontentprovider W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
  07-31 22:58:46.467 3100-3113/prakhar.mediacontentprovider W/art: Suspending all threads took: 12.472ms
  </code></pre>
  
      
  
  <pre><code>import android.content.ContentResolver;
  import android.database.Cursor;
  import android.provider.MediaStore; 
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.Toast;
  import java.util.ArrayList;
  
  public class MainActivity extends AppCompatActivity {
  
      private ListView songsList;
      private ArrayList&lt;String&gt; songRows = new ArrayList&lt;String&gt;();
      private ArrayAdapter&lt;String&gt; arrayAdpt;
      private int name, length;
      private Cursor cur;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          songsList = (ListView)findViewById(R.id.songslist);
  
          String[] requestColumns = {MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DURATION};
          try {
               cur = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, requestColumns, null, null, null);
          }
          catch(Exception ex){
               Toast.makeText(this, "Unknown Exception", Toast.LENGTH_LONG).show();
  
          }
          try{
              name = cur.getColumnIndex(MediaStore.Audio.Media.TITLE);
              length = cur.getColumnIndex(MediaStore.Audio.Media.DURATION);
          }
          catch(Exception ex){
              Toast.makeText(this, "Null Pointer Exception",     Toast.LENGTH_LONG).show();
          }
          try{
              cur.moveToFirst();
              while(!cur.isAfterLast()) {
                  songRows.add("Title "+cur.getString(name)+" Duration "+cur.getInt(length));
                  cur.moveToNext();
              }
          }
          catch(Exception ex){
              Toast.makeText(this, "Exception", Toast.LENGTH_LONG).show();
          }
  
          arrayAdpt = new ArrayAdapter&lt;String&gt;(this,         android.R.layout.simple_list_item_1, songRows);
          songsList.setAdapter(arrayAdpt);
      }
  }
  </code></pre>
  
  <p>On opening, the app throws an exception. What is wrong with this Code? </p>