Skip to content

Commit f7e8c1f

Browse files
committed
Catch SQL exceptions and return a null product
1 parent 1dc993b commit f7e8c1f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

core/src/main/java/io/snabble/sdk/ProductDatabase.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,7 @@ public boolean isUpdating() {
541541

542542
private boolean deleteDatabase(File dbFile) {
543543
if (dbFile.exists()) {
544-
if (!application.deleteDatabase(dbFile.getName())) {
545-
return false;
546-
}
544+
return application.deleteDatabase(dbFile.getName());
547545
}
548546
return true;
549547
}
@@ -769,7 +767,12 @@ private Cursor rawQuery(String sql, String[] args, CancellationSignal cancellati
769767
Cursor cursor;
770768

771769
synchronized (dbLock) {
772-
cursor = db.rawQuery(sql, args, cancellationSignal);
770+
try {
771+
cursor = db.rawQuery(sql, args, cancellationSignal);
772+
} catch (Exception e) {
773+
// query could not be executed
774+
return null;
775+
}
773776
}
774777

775778
//query executes when we call the first function that needs data, not on db.rawQuery

0 commit comments

Comments
 (0)