From ed0df2803f96ac3f586fc40660b08b893fe407fe Mon Sep 17 00:00:00 2001 From: Markus Doits Date: Thu, 30 Dec 2010 13:39:46 +0000 Subject: Allow to regenerate shared preferences I encountered a problem that changing preferences in APG did not change the preferences in ApgService after it was called once: 1. call getPreferences 2. change settings in APG 3. call getPreferences again --> the result at 3. was still having preferences from 1. To work around this, the function getPreferences has been updated to force the new generation of preferences while not breaking any other code relying on the old behaviour. --- src/org/thialfihar/android/apg/Preferences.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/org/thialfihar/android/apg/Preferences.java b/src/org/thialfihar/android/apg/Preferences.java index d22565804..e704d79f3 100644 --- a/src/org/thialfihar/android/apg/Preferences.java +++ b/src/org/thialfihar/android/apg/Preferences.java @@ -12,9 +12,13 @@ public class Preferences { private static Preferences mPreferences; private SharedPreferences mSharedPreferences; - public static synchronized Preferences getPreferences(Context context) + public static synchronized Preferences getPreferences(Context context) { + return getPreferences(context, false); + } + + public static synchronized Preferences getPreferences(Context context, boolean force_new) { - if (mPreferences == null) { + if (mPreferences == null || force_new) { mPreferences = new Preferences(context); } return mPreferences; -- cgit v1.2.3