diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-09-08 11:30:31 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-09-08 11:30:31 +0200 |
commit | 8ab2491645fb34677ee4bdbb9b8302f242419844 (patch) | |
tree | eafc0ac41a084d639bae9bd0284959ccd2a2b52f /OpenKeychain/src/main/java/org | |
parent | f4592c8b950f263e53edf55b86f13a1be4913704 (diff) | |
download | open-keychain-8ab2491645fb34677ee4bdbb9b8302f242419844.tar.gz open-keychain-8ab2491645fb34677ee4bdbb9b8302f242419844.tar.bz2 open-keychain-8ab2491645fb34677ee4bdbb9b8302f242419844.zip |
Make preferences safe across multiple processes
Diffstat (limited to 'OpenKeychain/src/main/java/org')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index e9ae5f99f..aa4621893 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -47,11 +47,18 @@ public class Preferences { public static synchronized Preferences getPreferences(Context context, boolean forceNew) { if (sPreferences == null || forceNew) { sPreferences = new Preferences(context); + } else { + // to make it safe for multiple processes, call getSharedPreferences everytime + sPreferences.updateSharedPreferences(context); } return sPreferences; } private Preferences(Context context) { + updateSharedPreferences(context); + } + + public void updateSharedPreferences(Context context) { // multi-process preferences if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mSharedPreferences = context.getSharedPreferences("APG.main", Context.MODE_MULTI_PROCESS); |