proper null checks and closing of cursors everywhere

This commit is contained in:
Vincent Breitmoser
2014-05-08 15:56:32 +02:00
parent 79117b1ef8
commit cbc3988628
6 changed files with 187 additions and 146 deletions

View File

@@ -690,8 +690,7 @@ public class KeychainIntentService extends IntentService
new String[]{KeyRings.MASTER_KEY_ID, KeyRings.HAS_ANY_SECRET},
selection, null, null);
try {
cursor.moveToFirst();
do {
if (cursor != null && cursor.moveToFirst()) do {
// export public either way
publicMasterKeyIds.add(cursor.getLong(0));
// add secret if available (and requested)
@@ -699,7 +698,9 @@ public class KeychainIntentService extends IntentService
secretMasterKeyIds.add(cursor.getLong(0));
} while (cursor.moveToNext());
} finally {
cursor.close();
if (cursor != null) {
cursor.close();
}
}
PgpImportExport pgpImportExport = new PgpImportExport(this, this, this);