@@ -134,8 +134,7 @@ public DBHelper(Context context)
134134 * @return true or false
135135 **/
136136 // endregion
137- public boolean executeDatabaseOperations (String tableName ,
138- String operations ,
137+ public boolean executeDatabaseOperations (String tableName , String operations ,
139138 LinkedHashMap <String , String > values ,
140139 boolean hasConditions ,
141140 LinkedHashMap <String , String > conditionalValues )
@@ -403,8 +402,7 @@ public Cursor executeSelectQuery(String query)
403402 * no matter condition is there or not
404403 **/
405404 // endregion COMMENTS FOR executeSelectQuery method
406- public Cursor executeSelectQuery (String tableName ,
407- String values ,
405+ public Cursor executeSelectQuery (String tableName , String values ,
408406 boolean hasConditions ,
409407 StringBuilder conditionalValues )
410408 {
@@ -505,11 +503,9 @@ public Cursor executeSelectQuery(String tableName,
505503 *
506504 **/
507505 //#endregion COMMENTS FOR executeSelectQuery method
508- public <T > ArrayList <T > executeSelectQuery (String tableName ,
509- String values ,
506+ public <T > ArrayList <T > executeSelectQuery (String tableName , String values ,
510507 boolean hasConditions ,
511- String conditionalValues ,
512- Class <T > tClass )
508+ String conditionalValues , Class <T > tClass )
513509 {
514510 try
515511 {
@@ -562,7 +558,7 @@ public <T> ArrayList<T> executeSelectQuery(String tableName,
562558 {
563559 // setting new instance of the class passed
564560 // for invoking the values returned from database
565- Object instance = tClass .newInstance ();
561+ T instance = tClass .newInstance ();
566562
567563 //#region LOOP FOR COUNT OF COLUMNS
568564 for (int j = 0 ; j < cursor .getColumnCount (); j ++)
@@ -634,7 +630,7 @@ else if (double.class == method.getParameterTypes()[0])
634630 }
635631 //#endregion LOOP FOR COUNT OF COLUMNS
636632
637- tArrayList .add (( T ) instance );
633+ tArrayList .add (instance );
638634 cursor .moveToNext ();
639635 }
640636 //#endregion LOOP FOR EXTRACTING DATA FROM DATABASE
@@ -692,10 +688,8 @@ else if (double.class == method.getParameterTypes()[0])
692688 *** @return this method will return the count of the record in the table
693689 **/
694690 // endregion COMMENTS FOR getRecordCount method
695- public int getRecordCount (String tableName ,
696- String values ,
697- boolean hasConditions ,
698- StringBuilder conditionalValues )
691+ public int getRecordCount (String tableName , String values ,
692+ boolean hasConditions , StringBuilder conditionalValues )
699693 {
700694 try
701695 {
@@ -961,7 +955,7 @@ public DBHelper createTable(String tableName)
961955 }
962956
963957 // checking if columns were provided or not for creating table
964- if (dbColumnArrayList == null || dbColumnArrayList .size () > 0 )
958+ if (dbColumnArrayList == null || dbColumnArrayList .size () == 0 )
965959 {
966960 Log .e (TAG , "createTable: No columns provided for creating table." );
967961 return this ;
@@ -1357,7 +1351,7 @@ public <T> ArrayList<T> getAllRecords(String tableName, boolean isAscending,
13571351 {
13581352 // setting new instance of the class passed
13591353 // for invoking the values returned from database
1360- Object instance = tClass .newInstance ();
1354+ T instance = tClass .newInstance ();
13611355
13621356 //#region LOOP FOR COUNT OF COLUMNS
13631357 for (int j = 0 ; j < cursor .getColumnCount (); j ++)
@@ -1428,7 +1422,7 @@ else if (double.class == method.getParameterTypes()[0])
14281422 }
14291423 //#endregion LOOP FOR COUNT OF COLUMNS
14301424
1431- tArrayList .add (( T ) instance );
1425+ tArrayList .add (instance );
14321426 cursor .moveToNext ();
14331427 }
14341428 //#endregion LOOP FOR EXTRACTING DATA FROM DATABASE
@@ -1529,7 +1523,7 @@ public <T> ArrayList<T> getAllRecords(String tableName, boolean isAscending,
15291523 {
15301524 // setting new instance of the class passed
15311525 // for invoking the values returned from database
1532- Object instance = tClass .newInstance ();
1526+ T instance = tClass .newInstance ();
15331527
15341528 //#region LOOP FOR COUNT OF COLUMNS
15351529 for (int j = 0 ; j < cursor .getColumnCount (); j ++)
@@ -1600,7 +1594,7 @@ else if (double.class == method.getParameterTypes()[0])
16001594 }
16011595 //#endregion LOOP FOR COUNT OF COLUMNS
16021596
1603- tArrayList .add (( T ) instance );
1597+ tArrayList .add (instance );
16041598 cursor .moveToNext ();
16051599 }
16061600 //#endregion LOOP FOR EXTRACTING DATA FROM DATABASE
0 commit comments