From b943f706b60538bc343e643879a607b389ebb1ca Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Thu, 27 May 2010 20:31:34 +0000 Subject: [PATCH] some coding practice and potential bug fixes --- src/org/thialfihar/android/apg/provider/Database.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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; }