使用SimpleCorsOrtreeAdapter管理Android中的游标的推荐方法是什么?

使用SimpleCorsOrtreeAdapter管理Android中的游标的推荐方法是什么?,android,cursor,android-cursoradapter,Android,Cursor,Android Cursoradapter,我有一个扩展ExpandableListActivity的类。为了填充此列表的数据,我使用了一个扩展SimpleCursorTreeAdapter的类。我有一个组(顶级)光标,看起来像这样: mGroupCursor = ((MyApplication)getApplication()). getDatabaseHelper().getGroupCursor(); startManagingCursor(mGroupCursor); 当然,我还需要提供子游标: @Override pr

我有一个扩展ExpandableListActivity的类。为了填充此列表的数据,我使用了一个扩展SimpleCursorTreeAdapter的类。我有一个组(顶级)光标,看起来像这样:

mGroupCursor = ((MyApplication)getApplication()).
    getDatabaseHelper().getGroupCursor();
startManagingCursor(mGroupCursor);
当然,我还需要提供子游标:

@Override
protected Cursor getChildCursor(Cursor groupCursor)
{
    Cursor childCursor = ((MyApplication)getApplication().
        getDatabaseHelper().
        getChildCursorForGroup(groupCursor.getInt(mGroupIdIndex));
    startManagingCursor(childCursor);
    return childCursor;
}
我的印象是,我可以在这些游标上调用StartMagingCursor,一切都会得到处理。显然情况并非如此,因为离开列表视图并使用“后退”按钮返回会引发异常,“无法继续活动:尝试重新查询已关闭的游标”或类似的情况

删除对
startManagingCursor()
的调用修复了问题,尽管我认为这不是正确的方法,因为在这种情况下,我不会在任何地方关闭游标


处理这些游标的推荐方法是什么?我在找一些简单轻便的东西。我的数据库是一个本地SQLite数据库,并且相对较小,因此只要性能不太慢,对我来说就不是问题。

startManagingCursor已经过时。我会考虑使用AsyncTask在后台获取光标,并自己设置观察者。

我真的希望有更容易实现的东西。在需要关闭打开的游标时,是否有一个方法可以覆盖以关闭它们?正如我所说,我使用的是一个小型的本地数据库,因此异步处理对于我所要做的事情来说似乎过于复杂了。最后我做了一些重构,现在我正在使用自己的自定义适配器。这对我来说效果更好。