title: SharedPreferences.getInt() results in ClassCastException - Why?
body: <p>I have a simple (not user-editable) numerical setting defined in a preferences XML as follows:</p>
  
  <pre><code>&lt;EditTextPreference
    android:key="@string/numeric_val"
    android:defaultValue="0" /&gt;
  </code></pre>
  
  <p>And I read it using this simple statement:</p>
  
  <pre><code>sharedPrefs.getInt(getString(R.string.numeric_val), 3)
  </code></pre>
  
  <p>It works, but when I try to read it, <strong>for the first time after application install</strong>, it generates a <code>ClassCastException</code>.</p>
  
  <p>The <a href="http://developer.android.com/reference/android/content/SharedPreferences.html#getInt%28java.lang.String,%20int%29">documentation</a> says that <code>getInt()</code> <em>"Throws ClassCastException if there is a preference with this name that is not an int."</em> - and I know that this preference is clearly defined as an <code>&lt;EditTextPreference&gt;</code> (a string?) but, if this is the reason for the exception, how I am supposed to use <code>SharedPreferences.getInt()</code>?</p>
  
  <p>I know I can use  <code>SharedPreferences.getString()</code> instead and then do the parsing/conversion myself, but then what is the purpose of <code>SharedPreferences.getInt()</code>?</p>