Skip to content

Commit

Permalink
Closing the database causes crashes
Browse files Browse the repository at this point in the history
As found in the comments of cowbell#158 databases shouldn't be closed as per this comment from a Google Engineer on the subject. After some testing I have not been able to replicate the issue after removing all instances of database.close()
  • Loading branch information
Adam Burdette committed Jan 19, 2017
1 parent 3f75cca commit 1bb70fe
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/android/LocalStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public List<String> getAllItems() {
results.add(cursor.getString(1));
}
cursor.close();
database.close();
return results;
}

Expand All @@ -58,7 +57,6 @@ public String getItem(String key) {
value = cursor.getString(1);
}
cursor.close();
database.close();
}
return value;
}
Expand All @@ -85,7 +83,6 @@ public void setItem(String key, String value) {
database.insert(LocalStorageDBHelper.LOCALSTORAGE_TABLE_NAME,
null, values);
}
database.close();
}
}

Expand All @@ -100,7 +97,6 @@ public void removeItem(String key) {
database.delete(LocalStorageDBHelper.LOCALSTORAGE_TABLE_NAME,
LocalStorageDBHelper.LOCALSTORAGE_ID + "='" + key + "'",
null);
database.close();
}
}

Expand All @@ -111,6 +107,5 @@ public void clear() {
database = localStorageDBHelper.getWritableDatabase();
database.delete(LocalStorageDBHelper.LOCALSTORAGE_TABLE_NAME, null,
null);
database.close();
}
}

0 comments on commit 1bb70fe

Please sign in to comment.