Make sure the Cursor is initialized correctly before accessing data from it.

详细错误是:java.lang.IllegalStateException: Couldn't read row 0, col 2 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.

出现这个原因是因为我在获取Cursor中的字段时,获取了一个不存在的字段,例如,我原本要获取数据库book表中的bookId字段,结果获取的时候写成了bookiD,

while (cursor.moveToNext()) {
				int bookId = cursor.getInt(cursor.getColumnIndex("bookiD"));		
	}

注意:Android是区分大小写的,所以我们在获取的时候也要严格按照数据库表字段的大小写来获取数据;

你可能感兴趣的:(Exception,SQLite,Android,Android应用开发异常整理)