diff --git a/src/com/fsck/k9/Preferences.java b/src/com/fsck/k9/Preferences.java index 6f20e5b2f..155547208 100644 --- a/src/com/fsck/k9/Preferences.java +++ b/src/com/fsck/k9/Preferences.java @@ -123,6 +123,14 @@ public class Preferences { accountsInOrder.remove(account); } + try { + account.getRemoteStore().resetRemoteStore(account); + } catch (MessagingException e) { + Log.e(K9.LOG_TAG, "Failed to reset remote store for account " + + account.getUuid()); + e.printStackTrace(); + } + account.delete(this); if (newAccount == account) { diff --git a/src/com/fsck/k9/mail/Store.java b/src/com/fsck/k9/mail/Store.java index 426b67bfe..c60d899e1 100644 --- a/src/com/fsck/k9/mail/Store.java +++ b/src/com/fsck/k9/mail/Store.java @@ -209,5 +209,13 @@ public abstract class Store { return mAccount; } + public void resetRemoteStore(Account account) { + String uri = account.getStoreUri(); + if (uri.startsWith("local")) { + throw new RuntimeException( + "Asked to get non-local Store object but given LocalStore URI"); + } + sStores.remove(uri); + } }