SharedPreferences使用经验

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文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值