博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android入门之: SharedPreferences
阅读量:4680 次
发布时间:2019-06-09

本文共 744 字,大约阅读时间需要 2 分钟。

读取数据:

 

 

保存数据:

 

 

+++++++++++++++++++方法详解++++++++++++++++++++++++++++++

SharedPreferences综述:

使用 方法提供获取和修改preference的接口

对于任意指定的preferences集合, 所有的app共享同一个实例;

如果想要 修改preferces的话, 必须通过 对象; 该对象可以保证preference状态一致而且可以控制存储;他的各种get方法的返回对象必须在整个程序中是不可变的;

使用方法

 

摘要:

Interface for accessing and modifying preference data returned by . For any particular set of preferences, there is a single instance of this class that all clients share. Modifications to the preferences must go through an object to ensure the preference values remain in a consistent state and control when they are committed to storage. Objects that are returned from the various getmethods must be treated as immutable by the application.

转载于:https://www.cnblogs.com/greentomlee/p/4781461.html

你可能感兴趣的文章