android下可以方便的使用key-value的配置文件:

// S.PRE 配置文件的文件名
// S.PRE_STOP 配置文件里的key

//写入
SharedPreferences sp = getSharedPreferences(S.PRE, 0);
SharedPreferences.Editor editor = sp.edit();
//赋予false
editor.putBoolean(S.PRE_STOP, false);
editor.commit();

//读取
//需要指定默认值,如果配置文件没有或者里面没有这个key时的值
sp.getBoolean(S.PRE_STOP, false);

程序共享的数据可以简单的使用此种方式读写,比较的方便。

文件在哪里?

/data/data/程序名称/shared_prefs/{S.PRE}.xml
文件内容:

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<boolean name="STOP" value="true" />
</map>



原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
Tags:
发表评论
表情
emotemotemotemotemotemotemotemotemotemotemotemotemot
emotemotemotemotemotemotemotemotemotemotemotemot
打开HTML 打开UBB 打开表情 隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写
 

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐