Why does the AlertDialog crash on show()?
<p>I'm new to AlertDialogs and cannot get it to work with Cursors. The code below is in my onCreate() function and I know the Cursor has rows in it. Am I missing part of the creation code?</p>

<pre><code>AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);

// set title
alertDialogBuilder.setTitle("Choose a playlist");

// set dialog message
alertDialogBuilder.setCancelable(false);

// Add cursor items
alertDialogBuilder.setCursor(cursor, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int pos) {
        Toast.makeText(getApplicationContext(), "Clicked on: " + pos, Toast.LENGTH_SHORT).show();
    }
}, MediaStore.Audio.Media.DISPLAY_NAME);

// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();

// show it
alertDialog.show();
</code></pre>

<p>Cursor Builder:</p>

<pre><code>private Cursor getPlaylists() {
    String[] ARG_STRING = {
            MediaStore.Audio.Media._ID,
            MediaStore.Audio.Media.DATA,
            MediaStore.Audio.Media.DISPLAY_NAME,
            MediaStore.Audio.Media.IS_MUSIC
    };
    Cursor cursor = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                                               ARG_STRING,
                                               null,
                                               null,
                                               null);

    int nameColumn = cursor.getColumnIndex(MediaStore.Audio.Media.IS_NOTIFICATION);
    cursor.moveToFirst();
    for (int i=0; i&lt;5; i++)
        Toast.makeText(getApplicationContext(), "" + cursor.getString(nameColumn), Toast.LENGTH_SHORT).show();
    return cursor;
}
</code></pre>
