@@ -1926,13 +1926,24 @@ public <T> ArrayList<T> getAllRecords(String tableName, boolean isAscending,
1926
1926
Log .e (TAG , "getAllRecords: Table name was null or empty." );
1927
1927
return null ;
1928
1928
}
1929
+
1930
+ // checking if order by column name is not null and not empty for ascending order
1931
+ if (orderByColumnName != null && !orderByColumnName .isEmpty ())
1932
+ {
1933
+ Log .e (TAG , "getAllRecords: order by column name was null or empty." );
1934
+ return null ;
1935
+ }
1929
1936
1930
1937
// checking if isAscending is false
1931
1938
// and order by column name is not null and not empty for descending order
1932
- if (!isAscending && ( orderByColumnName != null && ! orderByColumnName . isEmpty ()) )
1939
+ if (!isAscending )
1933
1940
{
1934
1941
orderBy = " ORDER BY " + orderByColumnName + " DESC" ;
1935
1942
}
1943
+ else
1944
+ {
1945
+ orderBy = " ORDER BY " + orderByColumnName + " ASC" ;
1946
+ }
1936
1947
1937
1948
// checking if model class was provided or not
1938
1949
// it not then not proceeding further
@@ -2098,13 +2109,24 @@ public <T> ArrayList<T> getAllRecords(String tableName, boolean isAscending,
2098
2109
{
2099
2110
whereClause = " WHERE " + conditionalValues ;
2100
2111
}
2101
-
2112
+
2113
+ // checking if order by column name is not null and not empty for ascending order
2114
+ if (orderByColumnName != null && !orderByColumnName .isEmpty ())
2115
+ {
2116
+ Log .e (TAG , "getAllRecords: order by column name was null or empty." );
2117
+ return null ;
2118
+ }
2119
+
2102
2120
// checking if isAscending is false
2103
2121
// and order by column name is not null and not empty for descending order
2104
- if (!isAscending && ( orderByColumnName != null && ! orderByColumnName . isEmpty ()) )
2122
+ if (!isAscending )
2105
2123
{
2106
2124
orderBy = " ORDER BY " + orderByColumnName + " DESC" ;
2107
2125
}
2126
+ else
2127
+ {
2128
+ orderBy = " ORDER BY " + orderByColumnName + " ASC" ;
2129
+ }
2108
2130
2109
2131
// checking if model class was provided or not
2110
2132
// it not then not proceeding further
0 commit comments