diff --git a/src/com/android/email/MessagingController.java b/src/com/android/email/MessagingController.java index be1aa8d72..6a0f1e1d8 100644 --- a/src/com/android/email/MessagingController.java +++ b/src/com/android/email/MessagingController.java @@ -364,6 +364,8 @@ public class MessagingController implements Runnable { // Select generic sync or store-specific sync SyncResults results = synchronizeMailboxGeneric(account, folder); + // The account might have been deleted + if (results == null) return; mListeners.synchronizeMailboxFinished(account.mId, folder.mId, results.mTotalMessages, results.mAddedMessages.size(), @@ -771,6 +773,8 @@ public class MessagingController implements Runnable { // 2. Open the remote folder and create the remote folder if necessary Store remoteStore = Store.getInstance(account, mContext); + // The account might have been deleted + if (remoteStore == null) return null; Folder remoteFolder = remoteStore.getFolder(mailbox.mServerId); /* diff --git a/src/com/android/email/mail/Store.java b/src/com/android/email/mail/Store.java index 27c9492b8..bdf90391f 100644 --- a/src/com/android/email/mail/Store.java +++ b/src/com/android/email/mail/Store.java @@ -88,6 +88,8 @@ public abstract class Store { public synchronized static Store getInstance(Account account, Context context) throws MessagingException { HostAuth hostAuth = account.getOrCreateHostAuthRecv(context); + // An existing account might have been deleted + if (hostAuth == null) return null; Store store = sStores.get(hostAuth); if (store == null) { Context appContext = context.getApplicationContext();