Skip to content
Browse files

Fix bug: cursor not closed when getting database version.

  • Loading branch information...
1 parent 6d0f258 commit a17e1c687e7ce0ef63b4f526cb93629c7683aafa @Nilhcem committed Mar 10, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/com/nilhcem/frcndict/database/DatabaseHelper.java
View
9 src/com/nilhcem/frcndict/database/DatabaseHelper.java
@@ -154,10 +154,15 @@ public Cursor findById(int id) {
}
public String getDbVersion() {
+ String dbVersion = null;
+
Cursor c = mDb.query(Tables.METADATA_TABLE_NAME, new String[] {Tables.METADATA_KEY_VERSION},
null, null, null, null, null);
-
- return (c.moveToFirst()) ? c.getString(c.getColumnIndex(Tables.METADATA_KEY_VERSION)) : null;
+ if (c.moveToFirst()) {
+ dbVersion = c.getString(c.getColumnIndex(Tables.METADATA_KEY_VERSION));
+ }
+ c.close();
+ return dbVersion;
}
public Cursor searchHanzi(String search, Integer curPage) {

0 comments on commit a17e1c6

Please sign in to comment.
Something went wrong with that request. Please try again.