Skip to content

Commit 2d55c19

Browse files
committed
1. Correct get count query for getting count.
2. Updating library version.
1 parent 60ebec7 commit 2d55c19

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
defaultConfig {
1111
minSdkVersion 19
1212
targetSdkVersion 28
13-
versionCode 35 // this indicates the number of releases of library
14-
versionName "1.3.61" // this indicates the current version of library
13+
versionCode 36 // this indicates the number of releases of library
14+
versionName "1.3.62" // this indicates the current version of library
1515
}
1616

1717
buildTypes {

app/src/main/java/com/amit/db/DBHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public int getRecordCount(String tableName,
529529
if (conditionalValues != null)
530530
{
531531
// building conditional query
532-
query = "SELECT " + values + " FROM " + tableName + " WHERE " + conditionalValues.toString() + "";
532+
query = "SELECT COUNT(" + values + ") FROM " + tableName + " WHERE " + conditionalValues.toString() + "";
533533
Log.e(TAG, "getRecordCount: query with condition is: " + query);
534534
}
535535
else
@@ -541,7 +541,7 @@ public int getRecordCount(String tableName,
541541
}
542542
else
543543
{
544-
query = "SELECT " + values + " FROM " + tableName + "";
544+
query = "SELECT COUNT(" + values + ") FROM " + tableName + "";
545545
Log.e(TAG, "getRecordCount: query without condition is: " + query);
546546
}
547547

app/src/main/java/com/amit/db/Database.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void onCreate(SQLiteDatabase db)
5757
* OR
5858
* SELECT * FROM TABLE_NAME WHERE ID = 1
5959
**/
60-
public int getRecordCount(String query)
60+
int getRecordCount(String query)
6161
{
6262
try
6363
{
@@ -67,7 +67,7 @@ public int getRecordCount(String query)
6767
if (cursor != null)
6868
{
6969
cursor.moveToFirst();
70-
count = cursor.getCount();
70+
count = cursor.getInt(0);
7171
cursor.close();
7272
return count;
7373
}

0 commit comments

Comments
 (0)