title: Which Preference Class for an Integer?
body: <p>To store an integer in an Android preference, I would intuitively go for <code>EditTextPreference</code> and do the usual String-int-String conversions.</p>
  
  <p>But then I came across a piece of code that stores an integer in a <code>&lt;ListPreference&gt;</code> instead:</p>
  
  <pre><code>&lt;ListPreference 
    android:key="@string/total_score"
    android:defaultValue="0" /&gt;
  </code></pre>
  
  <p>and retrieves it using <code>preferences.getInt(getString(R.string.total_score), 0);</code></p>
  
  <p>Does this really work? If so, how?</p>
  
  <p>Is it considered acceptable practice?</p>
  
  <p><strong>UPDATE:</strong> Thanks to the answers below, I have been able to find the implementation source code for <a href="http://google.com/codesearch#zK3VeWq4s9c/trunk/android-cpp-sdk/platforms/android-7/android/content/SharedPreferences.hpp&amp;q=SharedPreferences%20package:android&amp;type=cs" rel="nofollow">getInt()</a>. I am posting it here for easy reference:</p>
  
  <pre><code>jint android::content::SharedPreferences::getInt(local_ref&lt; java::lang::String &gt; const &amp;a0, jint a1)
  {
          return call_method&lt;
                  android::content::SharedPreferences::J2CPP_CLASS_NAME,
                  android::content::SharedPreferences::J2CPP_METHOD_NAME(2),
                  android::content::SharedPreferences::J2CPP_METHOD_SIGNATURE(2),
                  jint
          &gt;(get_jobject(), a0, a1);
  }
  </code></pre>