StringPreference extends Preference<String> { @Override public boolean exists() { return !TextUtils.isEmpty(get()); } StringPreference(final String name, final String key,
            @Nullable final String defaultValue); @Override boolean exists(); @Nullable @Override String get();  }
@Test public void testExists() throws Exception { assertFalse(mNullPref.exists()); mNullPref.set(""); assertFalse(mNullPref.exists()); mNullPref.set((String) null); assertFalse(mNullPref.exists()); mNullPref.set("qwerty"); assertTrue(mNullPref.exists()); mNullPref.delete(); assertFalse(mNullPref.exists()); assertFalse(mEmptyPref.exists()); mEmptyPref.set((String) null); assertFalse(mEmptyPref.exists()); mEmptyPref.set("Blah"); assertTrue(mEmptyPref.exists()); mEmptyPref.delete(); assertFalse(mEmptyPref.exists()); assertTrue(mHelloPref.exists()); mHelloPref.set(""); assertFalse(mHelloPref.exists()); mHelloPref.set("qrrbrbirlbel"); assertTrue(mHelloPref.exists()); mHelloPref.delete(); assertTrue(mHelloPref.exists()); }