diff --git a/src/org/thialfihar/android/apg/provider/Database.java b/src/org/thialfihar/android/apg/provider/Database.java index 6fee3888b..38c346086 100644 --- a/src/org/thialfihar/android/apg/provider/Database.java +++ b/src/org/thialfihar/android/apg/provider/Database.java @@ -178,7 +178,10 @@ public class Database extends SQLiteOpenHelper { } } while (cursor.moveToNext()); } - cursor.close(); + + if (cursor != null) { + cursor.close(); + } cursor = db.query(SecretKeys.TABLE_NAME, new String[]{ @@ -454,7 +457,10 @@ public class Database extends SQLiteOpenHelper { } else { rowId = mDb.insert(Keys.TABLE_NAME, Keys.KEY_DATA, values); } - c.close(); + + if (c != null) { + c.close(); + } return rowId; }