Android - Pass value through SharedPreferences

来源:互联网 发布:90后网络行为分析 编辑:程序博客网 时间:2024/05/22 04:37

Android - Pass value through SharedPreferences

//setSharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", 0);SharedPreferences.Editor editor = pref.edit();editor.putString("user_name",NAME);editor.commit();//getSharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", 0);String username = pref.getString("user_name", null);
1 0