Here is the code:
public List<XImage> getXImages()
{
List<XImage> images = new ArrayList<XImage>();
SQLiteDatabase database = this.getWritableDatabase();
String sql = String.format("SELECT %s, %s, %s FROM %s",
A, B, C, TABLE);
Cursor result = database.rawQuery(sql, null);
if (result.moveToFirst())
{
do
{
String a = result.getString(0);
String b = result.getString(1);
String c = result.getString(2);
XImage image = new XImage(a, b, c);
images.add(image);
}
while (result.moveToNext());
}
result.close();
database.close();
return images;
}
If after result.close();
I put database.close();
I get a runtime exception saying that it's trying to access SqliteDatabase while the connection is closed.
Does closing the cursor also close the database connection? If not, what should I be doing differently?