It seems that i cant fix this error msg.
I close the cursor correctly.. i tried even to create a new cursor with different reference name.. but this didnt work too.. what do i do wrong?
12-17 10:09:14.107: E/Cursor(277): Finalizing a Cursor that has not been deactivated or closed. database = /data/data/com.lernapp.src/databases/LernApp, table = Answers, query = SELECT Answer, Correct FROM Answers WHERE TestId = ? AND TestPageId = ?
private void getRowData(LernAppOpenHelper myDbHelper) {
String[] columnsTestPage = {"TestPageId", "Question","Picture"};
Cursor cursor = myDbHelper.getQuery("TestPage", columnsTestPage, "TestId = ?", new String[]{testNummer}, null, null, null);
startManagingCursor(cursor);
cursor.moveToFirst();
while(!cursor.isAfterLast()){
int testPageId = cursor.getInt(cursor.getColumnIndex("TestPageId"));
String question = cursor.getString(cursor.getColumnIndex("Question"));
String picture = cursor.getString(cursor.getColumnIndex("Picture"));
this.testPages.add(new TestPage(testPageId, question, picture));
cursor.moveToNext();
}
cursor.close();
columnsTestPage = null;
String[] columnsAnswers = {"Answer", "Correct"};
for(TestPage p: testPages){
cursor = myDbHelper.getQuery("Answers", columnsAnswers, "TestId = ? AND TestPageId = ?", new String[]{testNummer, p.getTestPageId()}, null, null, null);
cursor.moveToFirst();
while(!cursor.isAfterLast()){
String answer = cursor.getString(cursor.getColumnIndex("Answer"));
int correct = cursor.getInt(cursor.getColumnIndex("Correct"));
p.setAnswer(answer, correct);
cursor.moveToNext();
}
}
cursor.close();
}
if you use
startManagingCursor(cursor);there’s no need to close the cursor, Android will do it for you.Either remove
startManagingCursor(cursor);, or removecursor.close();references.EDIT:
Try this: