Android - 后退按钮无法正常工作。我认为这与光标未正确关闭有关

时间:2012-04-12 16:51:30

标签: android cursor back

我在Score.xml中的后退按钮不起作用,虽然我已经把finish()放入其中。但它适用于我的其他按钮。我的logcat中出现了这个错误:

04-13 00:27:23.459:E / Cursor(312):完成尚未停用或关闭的光标。 database = /data/data/com.memes/databases/dbemp.sqlite,table = score,query = SELECT score,difficulty,date FROM score ORDER BY score desc LIMIT 15

这是我在DBFunctions.java中的方法,是否将cursor.close()放在正确的位置?

public String getScore() {

    // TODO Auto-generated method stub
    String[] columns = new String[]{"score", "difficulty", "date"};
    Cursor c = db.query(tableScore, columns, null, null, null, null, "score desc", "15");
    String result = "";

    int iScore = c.getColumnIndex("score");
    int iDifficulty = c.getColumnIndex("difficulty");
    int iDate = c.getColumnIndex("date");

    for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
        result = result + " " + c.getString(iScore) + " " + c.getString(iDifficulty) + " " + c.getString(iDate) +"\n";
    }
    c.close();
    return result;
}

0 个答案:

没有答案