private void deleteAccounts() throws IOException { android.accounts.AccountManager am = AccountManager.get(MyContextHolder.get().context()); List<Account> aa = MyAccounts.getAccounts(MyContextHolder.get().context()); for (android.accounts.Account androidAccount : aa) { String logMsg = "Removing old account: " + androidAccount.name; MyLog.i(this, logMsg); AccountManagerFuture<Boolean> amf = am.removeAccount(androidAccount, null, null); try { amf.getResult(10, TimeUnit.SECONDS); } catch (OperationCanceledException | AuthenticatorException e) { MyLog.e(this, logMsg, e); throw new FileNotFoundException(logMsg + ", " + e.getMessage()); } } }