Is it possible to use sharedpreferences with a ListAdapter ? In my main activity I would like to set a flag that can be picked up in my listadapter Is this possbile ?
Regards
foud a solution meanwhile Hello, I've found it ...
in the main activity onCreate
final String PREF_FILE_NAME = "PrefFile";
SharedPreferences preferences = getSharedPreferences(PREF_FILE_NAME,MODE_PRIVATE);
Editor editor = preferences.edit();
editor.putBoolean("refresh", false);
editor.commit();
when 'refresh' is pushed
// Set "refresh" to true
SharedPreferences.Editor editor = getSharedPreferences("PrefFile", MODE_PRIVATE).edit();
editor.putBoolean("refresh", true);
editor.commit();
and in the listAdapter on GetView(own created, extend on SimpleAdapter)
// Get parent context
Context contextParent = parent.getContext();
// Get shared preferences
SharedPreferences sharedPreferences = contextParent.getSharedPreferences("PrefFile", context.MODE_PRIVATE);
// Refresh ?
if (sharedPreferences.getBoolean("refresh", false) == true) {
...
}