Android Shared Preferences
<p>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.`</p>

<pre><code>//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);
`
</code></pre>
