Android 使用SimplecursorAdapter时changeCursor崩溃

Android 使用SimplecursorAdapter时changeCursor崩溃,android,simplecursoradapter,Android,Simplecursoradapter,我被这个问题困扰了两天。 我有一个名为Mail\u Content\u SimpleCursor的自定义SimpleCursorAdapter,在我的主要活动中有以下代码: private Mail_Content_SimpleCursor mail_content_cusor; private Cursor mail_cursor; ListView Mail_contents; public void onCreate(Bundle savedInstanceState) {

我被这个问题困扰了两天。 我有一个名为Mail\u Content\u SimpleCursor的自定义SimpleCursorAdapter,在我的主要活动中有以下代码:

private Mail_Content_SimpleCursor mail_content_cusor;
private Cursor mail_cursor;
 ListView Mail_contents;
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
...
Mail_contents = (ListView)findViewById(R.id.mail_list_view_item);
mail_cursor = mDB.getMailData("gmail@gmail.com"); // Cursor query read recods from database
        startManagingCursor(mail_cursor);
        String[] from = new String[]{"mail_From","mail_Subject","mail_Content"};
        int[] to = new int[] {R.id.mail_list_from,R.id.mail_list_subject,R.id.mail_list_content};
        mail_content_cusor = new Mail_Content_SimpleCursor(this, R.layout.main_mail_list_item, mail_cursor, from, to);
Mail_contents.setAdapter(mail_content_cusor);

}
然后,我想用一个函数改变游标,以获得其他条件的记录

public void change(){
    mail_cursor = mDB.getMailData("yahoo@gmail.com"); // change where clause in query
    startManagingCursor(mail_cursor);
    mail_content_cusor.changeCursor(mail_cursor);
}
但是changeCursor函数使我的应用程序因此错误而崩溃

09-22 14:07:18.189: E/AndroidRuntime(31931): java.lang.IllegalStateException: attempt to re-open an already-closed object: android.database.sqlite.SQLiteQuery (mSql = SELECT * FROM mail_contents WHERE mail_user='gmail@gmail.com') 
试着改用

根据文件:


SwapCursor:在新游标中交换,返回旧游标。与changeCursor(游标)不同,返回的旧游标不会关闭。

还显示邮件内容或类代码内容提供程序和游标加载程序如何?您好。我解决了这个问题。只需在changeCursor之前调用stopManagingCursor(mail\u cursor)