SharedPreferences使用經驗
發表時間:2020-10-19
發布人:葵宇科技
浏覽次數:34
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是沒有意義的,這個(gè)标記表示文(wén)件可(kě)以追加,即可(kě)以持續向一個(gè)txt琅绫擎寫器(qì)械,而MODE_PRIVATE 活着其他 會覆蓋文(wén)件
2、當應用這幾種權限時,其他法度榜樣拜訪數據時啟動(dòng)本法度榜樣修改文(wén)件數據,其他法度榜樣獲得的┞氛樣緩存數據得不到最新的數據,其他法度榜樣要想獲得最新數據,本法度榜樣在寫文(wén)件時必須應用MODE_MULTI_PROCESS權限。
如(rú)不雅不經由過程創建Context拜訪其他應用的preference,可(kě)以以攫取xml文(wén)件方法直接拜訪其他應用preference對應的xml文(wén)件