I was wondering if anyone could give me a brief overview of Android Cursors. A few specific questions:
1 - I have a method that 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;
}
To housekeeping, I tried db.close () immediately before the return statement. However, this resulted in the returned cursor containing no rows. Why is this?
2 - What is the difference between closing the cursor and closing the database?
3 - Do I need to close the cursor if it is a local variable, or can I leave it to the garbage collector for cleaning?
4 - My database is small and is used only by my application - can I just open it?
barry