«

SharedPreferences中的MODE_APPEND 和 MODE_PRIVATE 区别

时间:2024-3-2 19:11     作者:韩俊     分类: Android


public static final int MODE_PRIVATE

Added in API level 1
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).


public static final int MODE_APPEND

Added in API level 1
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.

从SDK对于这两个常量的描述来看,他们控制的功能不一样



MODE_APPEND 的功能是判断是否有该文件,如果有在后面添加,而不是擦除



MODE_PRIVATE 该文件只能被创建他的应用访问(控制访问权限)



功能不同

标签: android

热门推荐