使用SharedPreference保存用户数据的步骤

1. 声明 SharedPreferences sp; 

2. 初始化 sp = this.getSharedPreferences("文件名", 0);//0代表的是私有

3. 获取sp的编辑器 Editor editor = sp.edit();

4. 存储数据 editer.putString()     putBoolean()     putLong()

5. 最后一步重要,一定要记得commit() 数据才被保存

原文地址:https://www.cnblogs.com/wanghaoyuhappy/p/5252548.html