首页 > 其他 > 详细

SharedPreferences使用经验

时间:2015-01-06 18:05:06      阅读:137      评论:0      收藏:0      [点我收藏+]

SharedPreferences使用经验


int

MODE_APPEND

File creation mode: for use with openFileOutput(String, int), if the file already exists then write data to the end of the existing file instead of erasing it.

int

MODE_MULTI_PROCESS

SharedPreference loading flag: when set, the file on disk will be checked for modification even if the shared preferences instance is already loaded in this process.

int

MODE_PRIVATE

File creation mode: the default mode, where the created file can only be accessed by the calling application (or all applications sharing the same user ID).

int

MODE_WORLD_READABLE

File creation mode: allow all other applications to have read access to the created file.

int

MODE_WORLD_WRITEABLE

File creation mode: allow all other applications to have write access to the created file.

1、对于SharedPreferences来说,使用MODE_APPEND是没有意义的,这个标志表示文件可以追加,即可以继续向一个txt里面写东西,而MODE_PRIVATE 活着其他  会覆盖文件

2、当使用这几种权限时,其他程序访问数据时启动本程序修改文件数据,其他程序得到的还是缓存数据得不到最新的数据,其他程序要想得到最新数据,本程序在写文件时必须使用MODE_MULTI_PROCESS权限。
如果不通过创建Context访问其他应用的preference,可以以读取xml文件方式直接访问其他应用preference对应的xml文件

SharedPreferences使用经验

原文:http://blog.csdn.net/dale_dede/article/details/42460301

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!