網頁

2011年11月22日 星期二

Android錯誤排除_Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it

使用SQLite的時候,很有可能出現這個訊息:

『Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it』

意思是沒辦法讀取CursorWindow這個Cursor的第0行,請確定訪問Cursor之前,已經完成初始化的動作。

這時候,我們會一直去看有沒有初始化,然後找不到錯誤;

這錯誤有可能是因為去讀取沒有定義的欄位名稱。

例:
String dis_Explore = cursor.getString(cursor.getColumnIndex("dis_Explore"));
但是欄位中並沒有dis_Explore這個欄位。

這樣的錯誤很有可能發生在資料庫定義改變或是增刪欄位時。

沒有留言:

張貼留言