Skip to content

Commit

Permalink
Throws runtime exception if cursor doesn't open properly
Browse files Browse the repository at this point in the history
  • Loading branch information
shobhitagarwal1612 committed Mar 3, 2018
1 parent fe4cfea commit 8b12268
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ private FormsDaoHelper() {

}

/**
* Returns the number of rows with the given query.
* If the cursor fails to open then returns -1.
*/
public static int getFormsCount(String selection, String[] selectionArgs) {
int count = -1;
try (Cursor c = new FormsDao().getFormsCursor(selection, selectionArgs)) {
if (c != null) {
count = c.getCount();
}
}
return count;
if (count == -1) {
throw new RuntimeException("Could not open the cursor properly");
} else {
return count;
}
}

public static String getFormPath(String selection, String[] selectionArgs) {
Expand Down

0 comments on commit 8b12268

Please sign in to comment.