0

这是我的方法高分

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 行 col - 1??我听不懂

4

3 回答 3

1

您收到此错误的原因是您的查询仅返回 TIME 列。您必须修改查询以SELECT MIN(TIME), MOVE, GRID FROM HIGHSCORE3;返回您要查找的所有列。

希望这可以帮助。:)

于 2013-06-02T07:19:49.777 回答
0

请更改表中列的名称time并在此之后检索数据。因为这是已经存储在database schema. 请更改列的名称并再次检查所有内容。我希望它会正常工作。

于 2013-06-02T06:49:18.800 回答
0

我粗你的光标没有得到计数然后抛出异常,

Cursor gethighscorealter = highscoreDB.rawQuery("SELECT MIN(TIME) FROM HIGHSCORE3;"
               , null);

    if(gethighscorealter.getCount() > 0){
        gethighscorealter.moveToFirst();
        timer= gethighscorealter.getInt(gethighscorealter.getColumnIndex("TIME"));
        move = gethighscorealter.getInt(gethighscorealter.getColumnIndex("MOVE"));
        grid = gethighscorealter.getInt(gethighscorealter.getColumnIndex("GRID"));
        highscoreview();
        gethighscorealter.close();

    }
于 2013-06-02T06:50:01.440 回答