title: SharedPreferences getLong() -> java.lang.String cannot be cast to java.lang.Long. How to fix?
body: <p>So there is a method <code>getLong()</code> of <code>SharedPreferences</code>. There is no way to declare <code>&lt;long-array&gt;</code> in <code>strings.xml</code>. So in which case we do use geLong()?</p>
  
  <p><code>strings.xml</code></p>
  
  <pre><code>&lt;string-array name="intervals"&gt;
      &lt;item&gt;Never&lt;/item&gt;
      &lt;item&gt;Minute&lt;/item&gt;
      &lt;item&gt;Fifteen&lt;/item&gt;
      &lt;item&gt;Half hour&lt;/item&gt;
      &lt;item&gt;An hour&lt;/item&gt;
      &lt;item&gt;Half day&lt;/item&gt;
      &lt;item&gt;Day&lt;/item&gt;
  &lt;/string-array&gt;
  &lt;string-array name="intervalValue"&gt;
      &lt;item&gt;0&lt;/item&gt;
      &lt;item&gt;60000&lt;/item&gt;
      &lt;item&gt;900000&lt;/item&gt;
      &lt;item&gt;1800000&lt;/item&gt;
      &lt;item&gt;3600000&lt;/item&gt;
      &lt;item&gt;86400000&lt;/item&gt;
  &lt;/string-array&gt;
  </code></pre>
  
  <p><code>Preferences.xml</code></p>
  
  <pre><code>&lt;ListPreference
      android:entries="@array/intervals"
      android:entryValues="@array/intervalValue"
      android:key="interval"
      android:summary="@string/summaryUpdaterInterval"
      android:title="@string/titleUpdaterInterval" &gt;
  </code></pre>
  
  <p></p>
  
  <p>code:</p>
  
  <pre><code>public long getInterval()
  {
      return prefs.getLong("interval", INTERVAL_NEVER);
  }
  </code></pre>
  
  <p>Causes:<br>
  <code>java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long</code></p>