3
嘿我在我的代碼中獲取索引超出界限的錯誤。遊標索引超出界限錯誤Android?
從活動:
Cursor cursor = mDbHelper.fetchA(b);
@SuppressWarnings("static-access")
int a = (int) cursor.getDouble(cursor.getColumnIndex(mDbHelper.KEY_I));
cursor.close();
我的DB適配器:
public Cursor fetchA(String b){
return mDb.query(DATABASE_TABLE, new String[] {KEY_I}, "b=\""+B+"\"", null, null, null, null);
}
錯誤:
E/AndroidRuntime(5766): FATAL EXCEPTION: main
E/AndroidRuntime(5766): android.database.CursorIndexOutOfBoundsException: Index
-1 requested, with a size of 1
我該如何解決這個問題?