I do not know what to do with it
It seems to work fine with Android 3.0 and above, but on Android 2.3.3 every time I run the application, it again asks for a username / password.
I use general settings.
This is how I save the settings:
SharedPreferences preferences = MyApplication.getAppContext().getSharedPreferences("athopbalance", MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putString("username", username).commit(); editor.putString("password", password).commit();
And here is how I read them:
SharedPreferences preferences = MyApplication.getAppContext().getSharedPreferences("athopbalance", Context.MODE_PRIVATE); String username = preferences.getString("username", ""); String password = preferences.getString("password", "");
I also tried to save the settings using this code:
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MyApplication.getAppContext()); SharedPreferences.Editor editor = preferences.edit(); editor.putString("username", username).commit(); editor.putString("password", password).commit();
And read them with this code:
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MyApplication.getAppContext()); String username = preferences.getString("username", ""); String password = preferences.getString("password", "");
But that doesn't work either.
The problem is that before restarting the application, I see that they still exist. However, as soon as I restart, I get "(empty string) for the username and" "for the password.
Any ideas would be highly appreciated
android sharedpreferences
Vlad Spreys
source share