BooleanPreference extends Preference<Boolean> { @Override public boolean exists() { return contains() || getDefaultValue() != null; } BooleanPreference(final String name, final String key,
            @Nullable final Boolean defaultValue); @Override boolean exists(); @Nullable @Override Boolean get(); void toggle();  }
@Test public void testExists() throws Exception { assertFalse(mNullPref.exists()); mNullPref.set(Boolean.TRUE); assertTrue(mNullPref.exists()); mNullPref.delete(); assertFalse(mNullPref.exists()); assertTrue(mFalsePref.exists()); mFalsePref.set(Boolean.TRUE); assertTrue(mFalsePref.exists()); mFalsePref.delete(); assertTrue(mFalsePref.exists()); assertTrue(mTruePref.exists()); mTruePref.set(Boolean.FALSE); assertTrue(mTruePref.exists()); mTruePref.delete(); assertTrue(mTruePref.exists()); }