Prefser { public int size() { return preferences.getAll().size(); } Prefser(@NonNull Context context);  Prefser(@NonNull Context context, @NonNull JsonConverter jsonConverter);  Prefser(@NonNull SharedPreferences sharedPreferences); @SuppressLint("CommitPrefEdits")  Prefser(@NonNull SharedPreferences sharedPreferences,
      @NonNull JsonConverter jsonConverter); SharedPreferences getPreferences(); boolean contains(String key); Observable<T> getAndObserve(String key, Class<T> classOfT, T defaultValue); Observable<T> getAndObserve(final String key, final TypeToken<T> typeTokenOfT,
      final T defaultValue); Observable<T> observe(@NonNull String key, @NonNull Class<T> classOfT,
      T defaultValue); Observable<T> observe(@NonNull final String key,
      @NonNull final TypeToken<T> typeTokenOfT, final T defaultValue); T get(@NonNull String key, @NonNull Class<T> classOfT, T defaultValue); T get(@NonNull String key, @NonNull TypeToken<T> typeTokenOfT, T defaultValue); Observable<String> observePreferences(); void put(@NonNull String key, @NonNull T value); void put(@NonNull String key, @NonNull T value, @NonNull TypeToken<T> typeTokenOfT); void remove(@NonNull String key); void clear(); int size();  }
@Test public void testSize() throws Exception { prefser.clear(); String keyToRemove = "key1"; prefser.put(keyToRemove, 1); prefser.put("key2", 2); prefser.put("key3", 3); assertThat(prefser.size()).isEqualTo(3); prefser.remove(keyToRemove); assertThat(prefser.size()).isEqualTo(2); prefser.clear(); assertThat(prefser.size()).isEqualTo(0); }