SharedPreferences使用经验
发表时间:2020-10-19
发布人:葵宇科技
浏览次数:46
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文件