Problem with SimpleCursorAdapter
<p>I'm trying to create a list activity that uses a SimpleCursorAdapter, but it just won't work. I know I'm getting the cursor correctly because when I have it print out to text all the values are there and I know there's nothing wrong with the SimpleCursorAdapter class because when I used it with the Image Content Provider it displayed correctly. However, when I try to put the two together my application crashes when I try to open the activity. My source code is below.</p>

<pre><code>package com.mao.crypt;
</code></pre>

<p>import android.app.ListActivity;</p>

<p>import android.content.Intent;</p>

<p>import android.database.Cursor;</p>

<p>import android.database.sqlite.SQLiteDatabase;</p>

<p>import android.os.Bundle;</p>

<p>import android.view.View;</p>

<p>import android.widget.ListView;</p>

<p>import android.widget.SimpleCursorAdapter;</p>

<p>public class OpenActivity extends ListActivity{</p>

<pre><code>Cursor cursor;

@Override

public void onCreate(Bundle icicle){

    super.onCreate(icicle);

    SQLiteDatabase db = new NotesDBHelper(getApplicationContext()).getReadableDatabase();

    cursor = db.rawQuery("SELECT _id,title,text FROM notes ORDER BY title ASC", null);

    startManagingCursor(cursor);

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, 

        android.R.layout.simple_list_item_2, cursor, 

        new String[]{"title","text"}, 

        new int[]{android.R.id.text1, android.R.id.text2});

    setListAdapter(adapter);

}

public void onDestroy(){

    cursor.close();

}

@Override

public void onListItemClick(ListView l, View v, int position, long id){

    cursor.moveToPosition(position);

    String title=cursor.getString(0);

    Intent data = new Intent();

    data.putExtra("title", title);

    setResult(RESULT_OK,data);

    finish();

}
</code></pre>

<p>}</p>
