diff --git a/app/src/main/java/com/etesync/syncadapter/resource/LocalAddressBook.java b/app/src/main/java/com/etesync/syncadapter/resource/LocalAddressBook.java index fd3498b8..5a2f3108 100644 --- a/app/src/main/java/com/etesync/syncadapter/resource/LocalAddressBook.java +++ b/app/src/main/java/com/etesync/syncadapter/resource/LocalAddressBook.java @@ -33,6 +33,7 @@ import android.support.v4.os.OperationCanceledException; import com.etesync.syncadapter.App; import com.etesync.syncadapter.model.CollectionInfo; import com.etesync.syncadapter.model.JournalEntity; +import com.etesync.syncadapter.utils.AndroidCompat; import com.etesync.syncadapter.utils.Base64; import java.io.ByteArrayOutputStream; @@ -143,12 +144,7 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect public void delete() { AccountManager accountManager = AccountManager.get(context); - if (Build.VERSION.SDK_INT >= - Build.VERSION_CODES.LOLLIPOP_MR1) { - accountManager.removeAccountExplicitly(account); - } else { - accountManager.removeAccount(account, null, null); - } + AndroidCompat.removeAccount(accountManager, account); } public LocalAddressBook(Context context, Account account, ContentProviderClient provider) { diff --git a/app/src/main/java/com/etesync/syncadapter/utils/AndroidCompat.java b/app/src/main/java/com/etesync/syncadapter/utils/AndroidCompat.java new file mode 100644 index 00000000..36148eba --- /dev/null +++ b/app/src/main/java/com/etesync/syncadapter/utils/AndroidCompat.java @@ -0,0 +1,16 @@ +package com.etesync.syncadapter.utils; + +import android.accounts.Account; +import android.accounts.AccountManager; +import android.os.Build; + +public class AndroidCompat { + public static void removeAccount (AccountManager accountManager, Account account) { + if (Build.VERSION.SDK_INT >= + Build.VERSION_CODES.LOLLIPOP_MR1) { + accountManager.removeAccountExplicitly(account); + } else { + accountManager.removeAccount(account, null, null); + } + } +}