@Test public void get_retrievesValueFromSharedPrefsByKey() { when(sharedPreferences.getString("key", null)).thenReturn("sampleValue"); String result = PersistentStore.get("key", context); assertEquals(result, "sampleValue"); }
static String get(String key, Context context) { Context applicationContext = context.getApplicationContext(); SharedPreferences sharedPreferences = applicationContext.getSharedPreferences(PREFERENCES_KEY, Context.MODE_PRIVATE); return sharedPreferences.getString(key, null); }
PersistentStore { static String get(String key, Context context) { Context applicationContext = context.getApplicationContext(); SharedPreferences sharedPreferences = applicationContext.getSharedPreferences(PREFERENCES_KEY, Context.MODE_PRIVATE); return sharedPreferences.getString(key, null); } }
PersistentStore { static String get(String key, Context context) { Context applicationContext = context.getApplicationContext(); SharedPreferences sharedPreferences = applicationContext.getSharedPreferences(PREFERENCES_KEY, Context.MODE_PRIVATE); return sharedPreferences.getString(key, null); }  }
PersistentStore { static String get(String key, Context context) { Context applicationContext = context.getApplicationContext(); SharedPreferences sharedPreferences = applicationContext.getSharedPreferences(PREFERENCES_KEY, Context.MODE_PRIVATE); return sharedPreferences.getString(key, null); }   }
PersistentStore { static String get(String key, Context context) { Context applicationContext = context.getApplicationContext(); SharedPreferences sharedPreferences = applicationContext.getSharedPreferences(PREFERENCES_KEY, Context.MODE_PRIVATE); return sharedPreferences.getString(key, null); }    }