it seems that closing a cursor, also attempt to close the Database
(printing a stacktrace):
at android.database.sqlite.SQLiteDatabase.dbclose(Native Method)
at
android.database.sqlite.SQLiteDatabase.onAllReferencesReleased(SQLiteDatabase.java:
325)
at
android.database.sqlite.SQLiteClosable.releaseReference(SQLiteClosable.java:
45)
at
android.database.sqlite.SQLiteProgram.onAllReferencesReleased(SQLiteProgram.java:
119)
at
android.database.sqlite.SQLiteClosable.releaseReference(SQLiteClosable.java:
45)
at android.database.sqlite.SQLiteProgram.close(SQLiteProgram.java:296)
at android.database.sqlite.SQLiteQuery.close(SQLiteQuery.java:136)
at android.database.sqlite.SQLiteCursor.close(SQLiteCursor.java:506)
does it mean that one shouldn't attempt closing a database explicitly
while using a cursor, as in this case:
SQLiteDatabase rdb = db.getReadableDatabase();
Cursor resultCursor = null;
String patternQuery = SQLiteQueryBuilder.buildQueryString(true,
"Store", columns, where, null, null, null, null);
try
{
resultCursor = rdb.rawQuery(patternQuery, null);
resultCursor.moveToFirst();
if (resultCursor.getCount() > 0)
{
while (!resultCursor.isAfterLast())
{
result.add(resultCursor.getString(0));
resultCursor.moveToNext();
}
}
}
catch (Exception e)
{
Log.d("DB", "Caught an exception while getting pattern
based results: " + e);
}
finally
{
if (resultCursor != null)
{
resultCursor.close();
}
if (rdb.isOpen())
{
rdb.close();
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en