invalid statement in fillwindow

1. 首先此问题发生原因是, android想使用cursor.requery(), 但是数据库连接关闭.

因为使用了startManagingCursor()函数, 按照api中描述:

This method allowsthe activity to take care of managing the given Cursor's lifecycle for youbased on the activity's lifecycle. That is, when the activity is stopped itwill automatically call deactivate() on the given Cursor, and when it is laterrestarted it will call requery() for you. When the activity is destroyed, allmanaged Cursors will be closed automatically.

可以看到, cursor声明周期将与Activity共同管理, 而当你返回List页时, 系统自动requery() 时, 但是DB连接已经关闭, 因为, 我在onStop方法中close()的.

2.解决方法, 在onDestroy中进行db close. 而且, 在从子Activity返回此parentActivity时, 也不需要renderListView(), 因为Android自动为我们从新requery啦


你可能感兴趣的:(statement)