S
so.r.u
Neues Mitglied
- 0
Hallo!
Ich habe eine Datenbankanfrage in meinem Programm, bekommen aber ständig IllegalStateExceptions wegen einem Cursor. Dabei schließe ich nach jeder Anfrage diesen Cursor:
Der c.close-Fall wird auch jedes Mal durchlaufen, nur danach ist c immer noch einSQLiteCursor, sollte es dann nicht null sein? Woran könnte das denn liegen? Ach ja das Ergebnis der Abfrage ist richtig.
Ich habe eine Datenbankanfrage in meinem Programm, bekommen aber ständig IllegalStateExceptions wegen einem Cursor. Dabei schließe ich nach jeder Anfrage diesen Cursor:
Code:
public WayPoint getLatestWayPoint(int route_id) {
Cursor c = null;
WayPoint w = null;
try {
c = db.query(WAYPOINTS, new String[] { "max(timestamp)" },
"route_id = ?", new String[] { route_id + "" }, null, null,
" timestamp ASC");
(...)
w = new WayPoint(id, route_id, timestamp, latitude, longitude, comment);
} catch (SQLException e) {
Log.e(TAG, "Database error fetching latest waypoint for route with id = " + route_id); }
if ( c != null ) {
c.close();
}
return w;
}