diff options
author | Arne Schwabe <arne@rfc2549.org> | 2012-05-20 14:36:00 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2012-05-20 14:36:00 +0200 |
commit | 376ecb5c8cb9dceb7cd88ea5527292e81712ec25 (patch) | |
tree | 6f00e49697c6553c4f319c0133e0ba2bf9500f6a /src/de/blinkt/openvpn/ProfileManager.java | |
parent | 42423ebf890bc51a9d8d24539fb05a200d878885 (diff) |
- Fix missing about
- Fix vpn list saving to sharedpreferences (closes issue #27)
- Version 0.5.5a
Diffstat (limited to 'src/de/blinkt/openvpn/ProfileManager.java')
-rw-r--r-- | src/de/blinkt/openvpn/ProfileManager.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/de/blinkt/openvpn/ProfileManager.java b/src/de/blinkt/openvpn/ProfileManager.java index d34bdbec..eb94505a 100644 --- a/src/de/blinkt/openvpn/ProfileManager.java +++ b/src/de/blinkt/openvpn/ProfileManager.java @@ -10,6 +10,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Set; +import de.blinkt.openvpn.R.string; + import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; @@ -23,6 +25,7 @@ public class ProfileManager { private static ProfileManager instance; private HashMap<String,VpnProfile> profiles=new HashMap<String, VpnProfile>(); + public static VpnProfile get(String key) { if(instance==null) return null; @@ -65,7 +68,14 @@ public class ProfileManager { SharedPreferences sharedprefs = context.getSharedPreferences(PREFS_NAME,Activity.MODE_PRIVATE); Editor editor = sharedprefs.edit(); editor.putStringSet("vpnlist", profiles.keySet()); - editor.commit(); + + // For reasing I do not understand at all + // Android saves my prefs file only one time + // if I remove the debug code below :( + int counter = sharedprefs.getInt("counter", 0); + editor.putInt("counter", counter+1); + editor.apply(); + } public void addProfile(VpnProfile profile) { @@ -99,8 +109,8 @@ public class ProfileManager { private void loadVPNList(Context context) { profiles = new HashMap<String, VpnProfile>(); - SharedPreferences settings =context.getSharedPreferences(PREFS_NAME,Activity.MODE_PRIVATE); - Set<String> vlist = settings.getStringSet("vpnlist", null); + SharedPreferences listpref = context.getSharedPreferences(PREFS_NAME,Activity.MODE_PRIVATE); + Set<String> vlist = listpref.getStringSet("vpnlist", null); Exception exp =null; if(vlist==null){ vlist = new HashSet<String>(); |