這是我的方法的高分當選擇光標SQL得到強制關閉
public void highscore(){
Cursor gethighscorealter = highscoreDB.rawQuery("SELECT MIN(TIME) FROM HIGHSCORE3;"
, null);
gethighscorealter.moveToFirst();
if(gethighscorealter!=null){
timer= gethighscorealter.getInt(gethighscorealter.getColumnIndex("TIME"));
move = gethighscorealter.getInt(gethighscorealter.getColumnIndex("MOVE"));
grid = gethighscorealter.getInt(gethighscorealter.getColumnIndex("GRID"));
highscoreview();
}
}
這是我的日誌貓
06-02 13:30:38.599: E/AndroidRuntime(32416): FATAL EXCEPTION: main
06-02 13:30:38.599: E/AndroidRuntime(32416): java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
06-02 13:30:38.599: E/AndroidRuntime(32416): at android.database.CursorWindow.nativeGetLong(Native Method)
06-02 13:30:38.599: E/AndroidRuntime(32416): at android.database.CursorWindow.getLong(CursorWindow.java:507)
06-02 13:30:38.599: E/AndroidRuntime(32416): at android.database.CursorWindow.getInt(CursorWindow.java:574)
06-02 13:30:38.599: E/AndroidRuntime(32416): at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:69)
06-02 13:30:38.599: E/AndroidRuntime(32416): at skripsi.slidame.PuzzleActivity.highscore(PuzzleActivity.java:253)
06-02 13:30:38.599: E/AndroidRuntime(32416): at skripsi.slidame.PuzzleActivity.onOptionsItemSelected(PuzzleActivity.java:131)
他們說行0山坳 - 1 ??我無法理解
thx我知道了,當我在w3schools.com上測試時,我看到只有1列被選中,所以即時通過ASC使用順序,我得到了該表中的最小值,但現在我正在考慮獲得最小值2列參數'TIME'和'MOVE' – user2375628
我明白了,'select min(time),min(move)from highscore3' 但是,我不能像往常一樣調用name列,必須'getnameindex(0)';當我看到在w3school.com列名更改爲'expr1000' – user2375628