Persistence { public void putString(String key, String value) { preferences.edit().putString(key, value).apply(); } Persistence(); @Nullable DataMap getDataMap(String key); void putDataMap(String key, DataMap dataMap); String getString(String key, String defaultValue); void putString(String key, String value); boolean getBoolean(String key, boolean defaultValue); void putBoolean(String key, boolean value); long whenDataUpdated(); Set<String> getSetOf(String key); void addToSet(String key, String value); void removeFromSet(String key, String value); static void storeDataMap(String key, DataMap dataMap); static Set<String> setOf(String key); static final String COMPLICATION_PROVIDER_PREFERENCES_FILE_KEY; }
@Test public void putStringTest() { Persistence persistence = new Persistence(); final String emptyGot = persistence.getString("test-key", "default-value"); persistence.putString("test-key", "newValue"); final String updatedGot = persistence.getString("test-key", "another-default-value"); assertThat(emptyGot, is("default-value")); assertThat(updatedGot, is("newValue")); }