I have to share preferences using the sharedpreferences class in android and the preferences have to be shared between two activities. How shall I pass these preferences from one activity to another activity? Static variables can be used but they're not working for me.
//code for setting shared preferences
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("login_session_key",response.getLogin_Session_Key());
editor.putString("user_name", username.getText().toString());
editor.commit();
//code for getting shared preferences
SharedPreferences settings = getSharedPreferences(SignIn.PREFS_NAME,
Activity.MODE_PRIVATE);
username = (TextView) findViewById(R.id.username);
String uname = settings.getString("user_name", null);
username.setText(uname);