0

我正在努力解决以下异常:

android.database.CursorWindowAllocationException
android.database.CursorWindow.<init>(CursorWindow.java:104)
android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:162)
android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156)
android.database.AbstractCursor.moveToPosition(AbstractCursor.java:161)
android.database.AbstractCursor.moveToFirst(AbstractCursor.java:201)
com.hyperlearning.library.Learning.getTotalScore(Learning.java:301)
...

我有以下代码:

public int getTotalScore(String categoryCode, int from, int to) {
    int repeat = Options.getInt(activity.getString(R.string.repeat_to_learn_key), 10);
    String sql =
        "select " +
            "sum(w1.enabled*w1.score), " +
            "sum((1-w1.enabled)*"+repeat+") " +
        "from words1 as w1 " + 
        "join categories_words1 as cw on cw.word1_id = w1.id " + 
        "join categories as ct on ct.id = cw.category_id " +
        "WHERE ct.name = '" + categoryCode + "' AND cw.position BETWEEN " + from + " AND " + to;
    Cursor cursor = db.rawQuery(sql, null);
    try {
        cursor.moveToFirst(); // *** Line 301 ***
        return cursor.getInt(0) + cursor.getInt(1);
    } finally {
        cursor.close();
    }
}

该错误主要发生在 Kindle Fire HD 上。

4

0 回答 0