使用 SharedPreferences 读写数据
来源:互联网 发布:mac电脑如何卸载sdk 编辑:程序博客网 时间:2024/05/18 03:48
public class SharedPreManager {private Context mContext;public SharedPreManager(Context context){mContext = context;}/** * 写数据 */public void writeData(String name,int age){SharedPreferences preferences = mContext.getSharedPreferences("xmlname",Context.MODE_PRIVATE );Editor editor = preferences.edit();editor.putString("name",name);editor.putInt("age",age);editor.commit();}/** * 读数据 */public Map<String,String> readData(){Map<String,String> params = new HashMap<String,String>();SharedPreferences preferences = mContext.getSharedPreferences("xmlname",Context.MODE_PRIVATE );params.put("name", preferences.getString("name", ""));params.put("age", String.valueOf(preferences.getInt("age", 0)));return params;}}
0 0
- 使用SharedPreferences读写数据
- 使用 SharedPreferences 读写数据
- 使用SharedPreferences读写数据
- 读写SharedPreferences中的数据
- SharedPreferences读写数据实例
- 读写SharedPreferences中的数据
- 读写SharedPreferences中的数据
- 【Android】安卓学习笔记之使用SharedPreferences 读写数据
- Android文件读写和使用SharedPreferences储存数据
- 读写SharedPreferences/PreferenceActivity中的数据
- Android之SharedPreferences读写数据
- 使用SharedPreferences读写配置信息
- 使用SharedPreferences处理数据
- 使用Sharedpreferences存取数据
- 使用SharedPreferences存取数据
- 使用SharedPreferences存储数据
- 使用SharedPreferences保存数据
- 使用SharedPreferences存储数据
- 部署微博自动爬取组件
- 新浪微博开发之二十八(原创微博frame)
- ROS新兵上路(二)ROS框架与文件系统
- 黑马程序员————浅谈面向对象
- 【机房收费系统】泛型与Datatable
- 使用 SharedPreferences 读写数据
- leetcode Next Permutation
- hdu 1203 I NEED A OFFER!
- 4月英语——just say it
- 汉化InnoSetup5.5
- play的字段验证
- 新浪微博开发之二十九(原创微博view)
- hdu 2036 ||nyoj1011 叉乘求多面形面积(无论是凸凹边形都可以)
- leetcode Remove Duplicates from Sorted Array