转载: http://blog.csdn.net/xzlawin/article/details/45959033


方法1:

存数据:

SharedPreferences userInfo = this.getSharedPreferences("user_info", 0);
userInfo.edit().putString("name", nameet.getText().toString()).commit();
userInfo.edit().putString("password", passwordet.getText().toString()).commit();

读数据

SharedPreferences userInfo = this.getSharedPreferences("user_info", 0);
nameet.setText(userInfo.getString("name", ""));
passwordet.setText(userInfo.getString("password", ""));


方法2:

存数据:

SharedPreferences setting = getSharedPreferences("setting", 0);
                SharedPreferences.Editor editor = setting.edit();
                editor.putString("apiUrl", "hello").commit();

读数据

SharedPreferences setting =  getSharedPreferences("setting", 0);
        String apiUrl=setting.getString("apiUrl","");



相关文章:

  • 2021-09-03
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2022-01-18
  • 2021-09-08
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2021-08-22
  • 2021-11-30
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
相关资源
相似解决方案