BinaryPreferences implements Preferences { @Override public String getString(String key, String defValue) { return (String) fetchStrategy.getValue(key, defValue); } BinaryPreferences(FileTransaction fileTransaction,
                      EventBridge eventsBridge,
                      CacheCandidateProvider cacheCandidateProvider,
                      CacheProvider cacheProvider,
                      TaskExecutor taskExecutor,
                      SerializerFactory serializerFactory,
                      LockFactory lockFactory,
                      FetchStrategy fetchStrategy); @Override Map<String, Object> getAll(); @Override String getString(String key, String defValue); @Override Set<String> getStringSet(String key, Set<String> defValue); @Override int getInt(String key, int defValue); @Override long getLong(String key, long defValue); @Override float getFloat(String key, float defValue); @Override boolean getBoolean(String key, boolean defValue); @SuppressWarnings("unchecked") @Override T getPersistable(String key, T defValue); @Override byte getByte(String key, byte defValue); @Override short getShort(String key, short defValue); @Override char getChar(String key, char defValue); @Override double getDouble(String key, double defValue); @Override byte[] getByteArray(String key, byte[] defValue); @Override boolean contains(String key); @Override PreferencesEditor edit(); @Override Set<String> keys(); @Override void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener); @Override void unregisterOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener);  }
@Test public void stringDefaultValue() { String defaultValue = "default value"; String restored = preferences.getString(key, defaultValue); assertEquals(defaultValue, restored); }