I would like to call the cache clear method when I click on a specific title on the settings screen in Android.
The problem is that onSharedPreferenceChanged is never called:
Here is the code snippet of my preferences .xml:
<header android:icon="@drawable/ic_action_cancel" android:title="Vider le cache d'articles" android:key="clearCache" android:summary="Clear all datas."> </header>
And here is my setup code:
package com.rss.preferences; import java.io.File; import java.util.List; import com.rss.R; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.util.Log; import android.view.Gravity; import android.widget.TextView; public class SettingsFragment extends PreferenceActivity { SharedPreferences settings; public static final String KEY_CLEAR_CACHE = "clearCache"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
source share