(OP 在问题编辑中回答的问题。转换为社区 wiki 答案。请参阅没有答案的问题,但问题在评论中解决(或在聊天中扩展))
OP写道:
我解决了这个问题。我的代码是:
public News getNewsWithID(int id){
Cursor c = bdd.query(TABLE_NEWS, new String[] {COL_ID, COL_ASSO, COL_DATE, COL_HEURE, COL_TYPE, COL_TITRE, COL_CONTENU, COL_SERVEURID}, COL_ID +"='"+ id +"'" , null, null, null, null);
return cursorToNews(c);
}
我改为:
public News getNewsWithID(int id){
Cursor c = bdd.query(TABLE_NEWS, new String[] {COL_ID, COL_ASSO, COL_DATE, COL_HEURE, COL_TYPE, COL_TITRE, COL_CONTENU, COL_SERVEURID}, COL_ID +"='"+ id +"'" , null, null, null, null);
News temp = cursorToNews(c);
c.close();
return temp;
}
我认为光标在 onDestroy() 上已关闭。