Well, I am beginner in Android and java, but I'm trying to learn.
My question is. I have these methods in my class (to save and load Sharedpreferences):
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();
}
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:
MyActivity1 A = new MyActivity1();
A.Save_pref("ACCOUNT","Myname");
The code compiles without problem, but the program crashes in this part of the code. Someone could help me solve this problem?
Thanks, Alexandre