Skip to content

Commit ff1115e

Browse files
committed
Do not close db
1 parent 6ea42d3 commit ff1115e

File tree

1 file changed

+1
-7
lines changed
  • library/src/main/java/com/absinthe/rulesbundle

1 file changed

+1
-7
lines changed

library/src/main/java/com/absinthe/rulesbundle/RuleDao.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ class RuleDao(context: Context) {
3232
db.setTransactionSuccessful()
3333
} finally {
3434
db.endTransaction()
35-
db.close()
3635
}
3736
}
3837

3938
fun deleteAllRules() {
4039
val db = dbHelper.writableDatabase
4140
db.delete("rules_table", null, null)
42-
db.close()
4341
}
4442

4543
suspend fun getRule(name: String): RuleEntity? = withContext(Dispatchers.IO) {
@@ -51,9 +49,7 @@ class RuleDao(context: Context) {
5149
arrayOf(name),
5250
null, null, null
5351
).use { cursor ->
54-
val entity = if (cursor.moveToFirst()) cursorToEntity(cursor) else null
55-
db.close()
56-
entity
52+
if (cursor.moveToFirst()) cursorToEntity(cursor) else null
5753
}
5854
}
5955

@@ -64,7 +60,6 @@ class RuleDao(context: Context) {
6460
while (cursor.moveToNext()) {
6561
list.add(cursorToEntity(cursor))
6662
}
67-
db.close()
6863
list
6964
}
7065
}
@@ -81,7 +76,6 @@ class RuleDao(context: Context) {
8176
while (cursor.moveToNext()) {
8277
list.add(cursorToEntity(cursor))
8378
}
84-
db.close()
8579
list
8680
}
8781
}

0 commit comments

Comments
 (0)