mardi 24 février 2015

Application did not close cursor, despite getting closed

I have an SQLite database in my Android Application. When I do one operation I always get a Finalizing a Cursor that has not been deactivated or closed. Here is the method:



public String getKey(){
net.sqlcipher.database.SQLiteDatabase db = this.getWritableDatabase(Login.authPass);
String selectQuery = "SELECT * FROM " + STABLE;
Cursor cursor = db.rawQuery(selectQuery, null); //This is the line that throws the exception
String s = cursor.getString(1);
cursor.close();
db.close();
return s;
}


It is really frustrating, because I am going to close the Cursor, it just throws an exception before it even gets there. Also I don't get how anything I'm doing on this line is considered finalizing the cursor. Thank you.


Aucun commentaire:

Enregistrer un commentaire