@@ -355,7 +355,8 @@ public Cursor executeSelectQuery(String query)
355
355
try
356
356
{
357
357
// query execution
358
- Cursor cursor = db .getReadableDatabase ().rawQuery (query , null );
358
+ Cursor cursor = db .getWritableDatabase ().rawQuery (query , null );
359
+ db .close ();
359
360
360
361
// if cursor is not null then moving the position to first
361
362
// and returning the cursor
@@ -450,7 +451,8 @@ public Cursor executeSelectQuery(String tableName, String values,
450
451
}
451
452
452
453
// executing query
453
- cursor = db .getReadableDatabase ().rawQuery (query , null );
454
+ cursor = db .getWritableDatabase ().rawQuery (query , null );
455
+ db .close ();
454
456
455
457
// if cursor is not null then moving the position to first
456
458
// and returning the cursor
@@ -553,7 +555,8 @@ public <T> ArrayList<T> executeSelectQuery(String tableName, String values,
553
555
}
554
556
555
557
// executing query
556
- cursor = db .getReadableDatabase ().rawQuery (query , null );
558
+ cursor = db .getWritableDatabase ().rawQuery (query , null );
559
+ db .close ();
557
560
558
561
// if cursor is not null then moving the position to first
559
562
// and returning the cursor
@@ -767,7 +770,8 @@ public boolean isTableExists(String tableName)
767
770
String query = "SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name = '" + tableName + "'" ;
768
771
769
772
// executing the query using cursor
770
- Cursor cursor = db .getReadableDatabase ().rawQuery (query , null );
773
+ Cursor cursor = db .getWritableDatabase ().rawQuery (query , null );
774
+ db .close ();
771
775
772
776
// checking if cursor is not null
773
777
if (cursor != null )
@@ -826,7 +830,8 @@ public int getMaxId(String field, String tableName)
826
830
}
827
831
828
832
String query = "SELECT MAX(" + field + ") AS ID FROM " + tableName ;
829
- Cursor cursor = db .getReadableDatabase ().rawQuery (query , null );
833
+ Cursor cursor = db .getWritableDatabase ().rawQuery (query , null );
834
+ db .close ();
830
835
831
836
if (cursor != null )
832
837
{
@@ -1957,7 +1962,8 @@ public <T> ArrayList<T> getAllRecords(String tableName, boolean isAscending,
1957
1962
Log .e (TAG , "getAllRecords: Select query for getting all records is: " + query );
1958
1963
1959
1964
// executing generated select query
1960
- cursor = db .getReadableDatabase ().rawQuery (query , null );
1965
+ cursor = db .getWritableDatabase ().rawQuery (query , null );
1966
+ db .close ();
1961
1967
1962
1968
// checking if cursor is not null and cursor has moved to first position
1963
1969
if (cursor != null && cursor .moveToFirst ())
@@ -2140,7 +2146,8 @@ public <T> ArrayList<T> getAllRecords(String tableName, boolean isAscending,
2140
2146
Log .e (TAG , "getAllRecords: Select query for getting all records is: " + query );
2141
2147
2142
2148
// executing generated select query
2143
- cursor = db .getReadableDatabase ().rawQuery (query , null );
2149
+ cursor = db .getWritableDatabase ().rawQuery (query , null );
2150
+ db .close ();
2144
2151
2145
2152
// checking if cursor is not null and cursor has moved to first position
2146
2153
if (cursor != null && cursor .moveToFirst ())
0 commit comments