mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-17 22:35:05 -05:00
Make preferences safe across multiple processes
This commit is contained in:
parent
f4592c8b95
commit
8ab2491645
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user