diff --git a/app/AndroidManifest.xml b/app/AndroidManifest.xml index 9f8801cc64..d2f2059dd3 100644 --- a/app/AndroidManifest.xml +++ b/app/AndroidManifest.xml @@ -1,7 +1,7 @@ diff --git a/app/src/main/java/com/quran/labs/androidquran/database/BookmarksDBAdapter.java b/app/src/main/java/com/quran/labs/androidquran/database/BookmarksDBAdapter.java index 170366913b..63f2337632 100644 --- a/app/src/main/java/com/quran/labs/androidquran/database/BookmarksDBAdapter.java +++ b/app/src/main/java/com/quran/labs/androidquran/database/BookmarksDBAdapter.java @@ -148,14 +148,25 @@ public long getBookmarkId(Integer sura, Integer ayah, int page) { open(); if (mDb == null){ return -1; } } - - Cursor cursor = mDb.query(BookmarksTable.TABLE_NAME, + + Cursor cursor = null; + try { + cursor = mDb.query(BookmarksTable.TABLE_NAME, null, BookmarksTable.PAGE + "=" + page + " AND " + BookmarksTable.SURA + (sura == null? " IS NULL" : "=" + sura) + " AND " + BookmarksTable.AYAH + (ayah == null?" IS NULL" : "=" + ayah), null, null, null, null); - if (cursor.moveToFirst()){ - return cursor.getLong(0); + if (cursor != null && cursor.moveToFirst()){ + return cursor.getLong(0); + } + } + catch (Exception e){ + // swallow the error for now + } + finally { + if (cursor != null){ + try { cursor.close(); } catch (Exception e){ } + } } return -1; }