最后确定还没有被停用或关闭非致命错误游标还没有、游标、错误

2023-09-12 08:31:59 作者:扶摇直上

我理解的没有被停用或结束写入光标 关闭的错误在这片code。 在code是用来填充列表视图。

由于这是一个非致命错误,没有死机和一切似乎工作 fine..but我不喜欢的错误。

如果我关闭游标在这个code..the列表视图的最后停留的 空。 如果我关闭游标中的onStop,我得到了同样的错误。

我要如何解决这个问题?

 私人无效updateList(){
        DBAdapter DB =新DBAdapter(本);
        db.open();
            //加载所有等待报警
            mCursor = db.getTitles(状态2);
            setListAdapter(新MyCursorAdapter(这一点,mCursor));
            registerForContextMenu(getListView());
            db.close();
        }


错误 :


E /光标(2318):最后确定尚未关闭游标
或关闭。数据库= /data/data/xxxxxxxxxxxxxxx.db,表=警报,
查询=选择_id,ALERT_ID,
E /光标(2318):
android.database.sqlite.DatabaseObjectNotClosedException:应用
没有关闭游标或数据库
对象,在这里开
E /光标(2318):在
。android.database.sqlite.SQLiteCursor< INIT>(SQLiteCursor.java:210)
E /光标(2318):在
android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:
53)
E /光标(2318):在
android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:
1345)
E /光标(2318):在
android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:
1229)
....
....
 

解决方案 外汇交易员投资过程中经常犯的致命错误,看看你中枪了没

您不应该得到的消息,如果你关闭了光标 的onStop ()的onDestroy()。请再试一次。或者,调用 startManagingCursor()后,你的光标从查询,而Android将关闭光标自己。

i'm getting a "Finalizing a Cursor that has not been deactivated or closed" error on this piece of code. The code is used to fill a listview.

Since it's a non-fatal error , there is no crash and all seems to works fine..but i don't like the error.

If i close the cursor at the end of this code..the listview stay's empty. if i close the cursor in onStop , i get the same error.

How do i fix this??

private void updateList() { 
        DBAdapter db = new DBAdapter(this); 
        db.open(); 
            //load all waiting alarm 
            mCursor=db.getTitles("state<2"); 
            setListAdapter(new MyCursorAdapter(this, mCursor)); 
            registerForContextMenu(getListView()); 
            db.close(); 
        } 


error : 


E/Cursor  ( 2318): Finalizing a Cursor that has not been deactivated 
or closed. database = /data/data/xxxxxxxxxxxxxxx.db, table = alerts, 
query = SELECT _id, alert_id, 
E/Cursor  ( 2318): 
android.database.sqlite.DatabaseObjectNotClosedException: Application 
did not close the cursor or database 
object that was opened here 
E/Cursor  ( 2318):      at 
android.database.sqlite.SQLiteCursor.<init>(SQLiteCursor.java:210) 
E/Cursor  ( 2318):      at 
android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDr­iver.java: 
53) 
E/Cursor  ( 2318):      at 
android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.j­ava: 
1345) 
E/Cursor  ( 2318):      at 
android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java­: 
1229) 
.... 
.... 

解决方案

You should not be getting that message if you close the Cursor in onStop() or onDestroy(). Please try that again. Or, call startManagingCursor() after you get the Cursor from your query, and Android will close the Cursor on its own.

 
精彩推荐
图片推荐