Android CheckBoxPreference java.lang.StackOverflowError
<p>I have this CheckBoxPreference in my code. I have implemented onSharedPreferenceChanged() in my code to perform some action. The problem is that when i click on the checkbox preference, the function gets called in a loop with same value. Can anyone help me with this?</p>

<p>Here are the relevant code snippets:</p>

<p>onSharedPreferenceChanged() section in preference activity:</p>

<pre><code>if(key.equals(LOCATION_UPDATE_KEY)) {
        boolean update = sharedPreferences.getBoolean(LOCATION_UPDATE_KEY, false);
        Log.v("preferences", update + "");
        editor.putBoolean(LOCATION_UPDATE_KEY, update);
        editor.commit();
}
</code></pre>

<p>preference activity's xml section:</p>

<pre><code>&lt;PreferenceCategory
    android:title="Location"&gt;
    &lt;CheckBoxPreference
        android:title="Track Location"
        android:defaultValue="false"
        android:summary="Keep track of handset location (Consumes Battery)"
        android:key="track_option" /&gt;
    &lt;ListPreference
        android:title="Location Update Source"
        android:summary=""
        android:key="track_source"
        android:defaultValue="2"
        android:entries="@array/location_sources"
        android:entryValues="@array/location_sources_values"
        android:dependency="track_option" /&gt;
    &lt;ListPreference
        android:title="Location Update Interval"
        android:summary=""
        android:key="track_interval"
        android:defaultValue="2"
        android:entries="@array/location_update_interval"
        android:entryValues="@array/location_update_interval_values"
        android:dependency="track_option" /&gt;
&lt;/PreferenceCategory&gt;
</code></pre>
