title: How to get Boolean value from Object
body: <p>I tried different ways to fix this, but I am not able to fix it. I am trying to get the Boolean value of an <strong>Object</strong> passed inside this method of a checkBox:</p>
  
  <pre><code>public boolean onPreferenceChange(Preference preference, Object newValue) 
  {
      final String key = preference.getKey();
      referenceKey=key;
      Boolean changedValue=!(((Boolean)newValue).booleanValue()); //ClassCastException occurs here
  }
  </code></pre>
  
  <p>I get:</p>
  
  <blockquote>
    <p>java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean</p>
  </blockquote>