From 4010802fabfc23558828c4995e6b426368e488c5 Mon Sep 17 00:00:00 2001 From: amitjangid80 Date: Fri, 30 Aug 2019 17:14:18 +0530 Subject: [PATCH] 1. Closing database for no memory leak. 2. Releasing new version v1.6.50. --- .idea/caches/build_file_checksums.ser | Bin 500 -> 541 bytes .idea/codeStyles/Project.xml | 116 ++++++++++++++++++++ app/src/main/java/com/amit/db/DBHelper.java | 21 ++-- 3 files changed, 130 insertions(+), 7 deletions(-) create mode 100644 .idea/codeStyles/Project.xml diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 1b5d4278621fd6a548af664045af961c43207e3c..2ee6d244cb6a3ebb019226e5e8cc4d36d33bb8b5 100644 GIT binary patch delta 92 zcmV-i0Hgo(1Dynrm;~Zf>j9CROaTUw={qkBVs&Y3WG-iNVPtG&b#VZG00sa601(uN y+@mQYoG42C4V0=t1{HJw5NvN_VQiD30TmFG1C|?u+4QIBZ@`9 + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+ \ No newline at end of file diff --git a/app/src/main/java/com/amit/db/DBHelper.java b/app/src/main/java/com/amit/db/DBHelper.java index b520ca5..3aa157a 100644 --- a/app/src/main/java/com/amit/db/DBHelper.java +++ b/app/src/main/java/com/amit/db/DBHelper.java @@ -355,7 +355,8 @@ public Cursor executeSelectQuery(String query) try { // query execution - Cursor cursor = db.getReadableDatabase().rawQuery(query, null); + Cursor cursor = db.getWritableDatabase().rawQuery(query, null); + db.close(); // if cursor is not null then moving the position to first // and returning the cursor @@ -450,7 +451,8 @@ public Cursor executeSelectQuery(String tableName, String values, } // executing query - cursor = db.getReadableDatabase().rawQuery(query, null); + cursor = db.getWritableDatabase().rawQuery(query, null); + db.close(); // if cursor is not null then moving the position to first // and returning the cursor @@ -553,7 +555,8 @@ public ArrayList executeSelectQuery(String tableName, String values, } // executing query - cursor = db.getReadableDatabase().rawQuery(query, null); + cursor = db.getWritableDatabase().rawQuery(query, null); + db.close(); // if cursor is not null then moving the position to first // and returning the cursor @@ -767,7 +770,8 @@ public boolean isTableExists(String tableName) String query = "SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name = '" + tableName + "'"; // executing the query using cursor - Cursor cursor = db.getReadableDatabase().rawQuery(query, null); + Cursor cursor = db.getWritableDatabase().rawQuery(query, null); + db.close(); // checking if cursor is not null if (cursor != null) @@ -826,7 +830,8 @@ public int getMaxId(String field, String tableName) } String query = "SELECT MAX(" + field + ") AS ID FROM " + tableName; - Cursor cursor = db.getReadableDatabase().rawQuery(query, null); + Cursor cursor = db.getWritableDatabase().rawQuery(query, null); + db.close(); if (cursor != null) { @@ -1957,7 +1962,8 @@ public ArrayList getAllRecords(String tableName, boolean isAscending, Log.e(TAG, "getAllRecords: Select query for getting all records is: " + query); // executing generated select query - cursor = db.getReadableDatabase().rawQuery(query, null); + cursor = db.getWritableDatabase().rawQuery(query, null); + db.close(); // checking if cursor is not null and cursor has moved to first position if (cursor != null && cursor.moveToFirst()) @@ -2140,7 +2146,8 @@ public ArrayList getAllRecords(String tableName, boolean isAscending, Log.e(TAG, "getAllRecords: Select query for getting all records is: " + query); // executing generated select query - cursor = db.getReadableDatabase().rawQuery(query, null); + cursor = db.getWritableDatabase().rawQuery(query, null); + db.close(); // checking if cursor is not null and cursor has moved to first position if (cursor != null && cursor.moveToFirst())