I understand that after closing the database, the cursor becomes "invalid", does it also close the cursor at the same time? Does this not allow you to do what is shown below?
Example 1
public void String getResultsAndReturnString() { String result = ""; SQLiteDatabase db = dbHelper.getReadableDatabase(); Cursor cursor = qb.query(db, projection, null, null, null, null, null); cursor.close(); <-- explicit cursor close example one db.close(); return result; }
example 2
public void Cursor getResultsAndReturnCursor(){ SQLiteDatabase db = dbHelper.getReadableDatabase(); Cursor cursor = qb.query(db, projection, null, null, null, null, null); return cursor; } public void closeOut(Cursor cursor, SQLiteDatabase dataBase){ cursor.close(); <-- explicit cursor close example two dataBase.close(); }
Kevik source share