SharedPreferences在Android中简单配置读写
2017-11-09 09:47
190 查看
在Android中可以通过SharedPreferences完成简单的配置的读取和记录,使用方法如下:
SharedPreferences对应的内容 实际上是以xml文件的形式保存在 : /data/data//shared_prefs/ 目录下
public static final String DATA= "data"; public static final String NAME = "name"; //从DATA文件中读取NAME字段 SharedPreferences settings = getSharedPreferences(DATA, 0); String username = settings.getString(NAME, ""); //将"xiaomi" 写入刚才得 NAME字段 settings.edit().putString(NAME, "xiaomi").commit();
SharedPreferences对应的内容 实际上是以xml文件的形式保存在 : /data/data//shared_prefs/ 目录下
相关文章推荐
- Android中简单配置读写,SharedPreferences的使用
- android文件的写入与读取---简单的文本读写context.openFileInput() context.openFileOutput()
- c++ 实现对配置文件的读写 根据windows API 函数简单改写
- mono for Android配置环境和listview简单显示数据(1)
- mono for Android配置环境和listview简单显示数据(2)
- android adb配置和查看数据库简单命令
- Android开发准备工作简单啦!---Android开发环境搭建及配置
- Android读写配置文件
- android文件的写入与读取---简单的文本读写context.openFileInput() context.openFileOutput()
- Android SD卡简单的文件读写操作
- android文件的写入与读取---简单的文本读写context.openFileInput() context.openFileOutput() .
- Android中Tomcat的简单配置和使用
- Android Jni 工程简单配置过程 (前提是环境搭建好 )
- 【Android】android文件的写入与读取---简单的文本读写context.openFileInput() context.openFileOutput()
- Android中使用C++程序读写Parcel的简单例子
- Android下的junit测试简单配置
- C# 读写配置文件的简单类
- android--简单的文件创建与读写操作
- c++ stl实现对配置文件的读写 根据windows API WritePrivateProfileString,GetPrivateProfileString简单改写
- XML::Simple 简单的读写xml(尤其适合配置文件)