@SuppressLint("CommitPrefEdits") @Test public void shouldCommitDeleteOperation() { BooleanPreference booleanPreference = BooleanPreference.newInstance(mockSharedPreferences, "key", false, true); booleanPreference.delete(); verify(mockEditor).remove("key"); verify(mockEditor).commit(); }
@SuppressLint("CommitPrefEdits") public void delete() { SharedPreferences.Editor editor = sharedPreferences.edit().remove(key); if (commit) { editor.commit(); } else { editor.apply(); } }
BasePreference { @SuppressLint("CommitPrefEdits") public void delete() { SharedPreferences.Editor editor = sharedPreferences.edit().remove(key); if (commit) { editor.commit(); } else { editor.apply(); } } }
BasePreference { @SuppressLint("CommitPrefEdits") public void delete() { SharedPreferences.Editor editor = sharedPreferences.edit().remove(key); if (commit) { editor.commit(); } else { editor.apply(); } } BasePreference(@NonNull SharedPreferences sharedPreferences, @NonNull String key,
      @Nullable T defaultValue, boolean commit); }
BasePreference { @SuppressLint("CommitPrefEdits") public void delete() { SharedPreferences.Editor editor = sharedPreferences.edit().remove(key); if (commit) { editor.commit(); } else { editor.apply(); } } BasePreference(@NonNull SharedPreferences sharedPreferences, @NonNull String key,
      @Nullable T defaultValue, boolean commit); boolean isSet(); @SuppressLint("CommitPrefEdits") void set(@Nullable T value); @SuppressLint("CommitPrefEdits") void delete(); abstract T get(); }
BasePreference { @SuppressLint("CommitPrefEdits") public void delete() { SharedPreferences.Editor editor = sharedPreferences.edit().remove(key); if (commit) { editor.commit(); } else { editor.apply(); } } BasePreference(@NonNull SharedPreferences sharedPreferences, @NonNull String key,
      @Nullable T defaultValue, boolean commit); boolean isSet(); @SuppressLint("CommitPrefEdits") void set(@Nullable T value); @SuppressLint("CommitPrefEdits") void delete(); abstract T get();  }