Make sure to close a cursor

b/17570154

Change-Id: I759a116a14784e92e7fa7eb51755ceda3860550e
This commit is contained in:
Martin Hibdon 2014-09-24 11:25:16 -07:00
parent f1b6b3afd9
commit 123d40283e

View File

@ -225,11 +225,17 @@ public final class Account extends EmailContent implements Parcelable {
new String[] {AccountColumns._ID},
AccountColumns.EMAIL_ADDRESS + "=?", new String[] {emailAddress},
null);
if (c == null || !c.moveToFirst()) {
return null;
try {
if (c == null || !c.moveToFirst()) {
return null;
}
final long id = c.getLong(c.getColumnIndex(AccountColumns._ID));
return restoreAccountWithId(context, id, observer);
} finally {
if (c != null) {
c.close();
}
}
final long id = c.getLong(c.getColumnIndex(AccountColumns._ID));
return restoreAccountWithId(context, id, observer);
}
@Override