title: How to remove Android preferences from the screen
body: <p>I'm trying to remove a preference from the screen so it isn't visible if the user is using an SDK greater than 2.2.  I've found several answers saying that getPreferenceScreen().removePreference(thePreference) will work, but I'm getting FALSE returned every time I try it. Am I using it in the wrong place? Any clue from my code?</p>
  
  <pre><code>public class Preferences extends PreferenceActivity implements OnSharedPreferenceChangeListener {
  
  private static final String POLLING_PREFERENCE = "update_frequency_list";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      // Load the preferences from an XML resource
      addPreferencesFromResource(R.xml.preferences);
  
      // Get a reference to the preferences
      mPollPref = getPreferenceScreen().findPreference(POLLING_PREFERENCE);
  
      //If the SDK is 2.2 or greater do not display polling preferences (using C2DM instead)
      if(Build.VERSION.SDK_INT &gt; 7) {
          getPreferenceScreen().removePreference(mPollPref);
      }
  }
  ....
  }
  </code></pre>