Skip to content

Commit

Permalink
when a db account is deleted, we need to reset user data referring to…
Browse files Browse the repository at this point in the history
… it in sync account manager
  • Loading branch information
mtotschnig committed Mar 21, 2017
1 parent d43cc52 commit c856f0c
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package org.totschnig.myexpenses.model;

import android.accounts.AccountManager;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
import android.content.ContentUris;
Expand All @@ -36,6 +37,7 @@
import org.totschnig.myexpenses.provider.filter.CrStatusCriteria;
import org.totschnig.myexpenses.provider.filter.WhereFilter;
import org.totschnig.myexpenses.sync.GenericAccountService;
import org.totschnig.myexpenses.sync.SyncAdapter;
import org.totschnig.myexpenses.util.AcraHelper;
import org.totschnig.myexpenses.util.Utils;

Expand Down Expand Up @@ -264,6 +266,12 @@ public static void delete(long id) throws RemoteException, OperationApplicationE
if (account == null) {
return;
}
if (account.getSyncAccountName() != null) {
AccountManager accountManager = AccountManager.get(MyApplication.getInstance());
android.accounts.Account syncAccount = GenericAccountService.GetAccount(account.getSyncAccountName());
accountManager.setUserData(syncAccount, SyncAdapter.KEY_LAST_SYNCED_LOCAL(account.getId()), null);
accountManager.setUserData(syncAccount, SyncAdapter.KEY_LAST_SYNCED_REMOTE(account.getId()), null);
}
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
ops.add(account.updateTransferPeersForTransactionDelete(
buildTransactionRowSelect(null),
Expand Down

0 comments on commit c856f0c

Please sign in to comment.