I was wondering if someone could give me a brief overview of Android Cursors. A couple of specific questions:
1 - I have a method which returns a cursor after a database query:
public static Cursor getVehicles()
{
SQLiteDatabase db = vehicleData.getReadableDatabase();
Cursor cursor = db.query(TABLE_NAME, GET_VEHICLES_FROM_CLAUSE, null, null, null, null, ORDER_BY);
return cursor;
}
In order to do housekeeping, I tried db.close() just before the return statement. However, this caused the returned cursor to contain no rows. Why is this?
2 - What's the difference between closing a cursor and closing a database?
3 - Do I need to call close on a Cursor if it is a local variable, or can I leave it to the garbage collector to clean up?
4 - My database is small and only used by my application - can I just keep it open?