Skip to content

Commit 5666b9e

Browse files
author
Landice Fu
committed
close cursor for checking table type
1 parent 563bbbc commit 5666b9e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

debug-db/src/main/java/com/amitshekhar/utils/DatabaseHelper.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,20 @@ public static TableDataResponse getTableData(SQLiteDatabase db, String selectQue
7272
final String pragmaQuery = "PRAGMA table_info(" + tableName + ")";
7373
tableData.tableInfos = getTableInfo(db, pragmaQuery);
7474
}
75-
Cursor cursor;
75+
Cursor cursor = null;
7676
boolean isView = false;
7777
try {
7878
cursor = db.rawQuery("SELECT type FROM sqlite_master WHERE name=?", new String[]{tableName});
7979
if (cursor.moveToFirst()) {
8080
isView = "view".equalsIgnoreCase(cursor.getString(0));
8181
}
82-
} catch (Exception e) {}
82+
} catch (Exception e) {
83+
e.printStackTrace();
84+
} finally {
85+
if (cursor != null) {
86+
cursor.close();
87+
}
88+
}
8389
tableData.isEditable = tableName != null && tableData.tableInfos != null && !isView;
8490

8591
try {

0 commit comments

Comments
 (0)