Sharedpreferences in android
<p>Well, I am beginner in Android and java, but I'm trying to learn.</p>

<p>My question is. I have these methods in my class (to save and load Sharedpreferences):</p>

<pre><code>private String Load_pref(String key){
    SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
    String strSavedMem1 = sharedPreferences.getString(key, "");        
    return strSavedMem1;
   } 

public void Save_pref(String key, String value){
    SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putString(key, value);
    editor.commit();
   }
</code></pre>

<p>Well, Its work well, but I would call these methods from another class (other screen activity). I tried to do this in my other activity:</p>

<pre><code>            MyActivity1 A = new MyActivity1();
            A.Save_pref("ACCOUNT","Myname"); 
</code></pre>

<p>The code compiles without problem, but the program crashes in this part of the code.
Someone could help me solve this problem?</p>

<p>Thanks,
Alexandre</p>
