sp存值取值

@Override
public void success(LoginBean loginBean) {
    Toast.makeText(this, "登录成功", Toast.LENGTH_LONG).show();
    SharedPreferences sp = getSharedPreferences("config", MODE_PRIVATE);
    sp.edit().putString("username",loginBean.getData().getUsername())
            .putString("login","true").putInt("uid",loginBean.getData().getUid())
            .putString("nickname",String.valueOf(loginBean.getData().getNickname())).commit();
    finish();
}

 

SharedPreferences sp = getSharedPreferences("config",MODE_PRIVATE);
int uid = sp.getInt("uid", 0);

你可能感兴趣的:(sp存值取值)