1. 声明 SharedPreferences sp; 

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

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

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

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

相关文章:

  • 2021-08-01
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2022-02-15
猜你喜欢
  • 2021-09-21
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2021-11-15
相关资源
相似解决方案