具有MODE_PRIVATE,MODE_WORLD_READABLE,MODE_WORLD_WRITABLE的Android SharedPreferences [英] Android SharedPreferences with MODE_PRIVATE,MODE_WORLD_READABLE,MODE_WORLD_WRITABLE
问题描述
SharedPreferences
是应用程序本地的,并且不在不同的应用程序之间共享.当我说
SharedPreferences
in Android are local to an Application, and not shared between different applications. When I say
SharedPreferences preferences = getSharedPreferences(PREF_NAME, MODE_WORLD_READABLE);
表示此首选项MODE_WORLD_READABLE
,MODE_WORLD_WRITABLE
或
MODE_PRIVATE
?
推荐答案
getSharedPreferences(String name, int mode)
解释了更多信息此处
编辑
从API 17开始,不推荐使用MODE_WORLD_READABLE
和MODE_WORLD_WRITEABLE
:
Edit
As of API 17, the MODE_WORLD_READABLE
and MODE_WORLD_WRITEABLE
are deprecated:
此常量在API级别17中已弃用.
创建世界可读的文件非常危险,并且可能导致应用程序中的安全漏洞.强烈建议不要这样做.相反,应用程序应使用更正式的机制进行交互,例如ContentProvider
,BroadcastReceiver
和Service
.无法保证此访问模式将保留在文件上,例如在进行备份和还原时.
This constant was deprecated in API level 17.
Creating world-readable files is very dangerous, and likely to cause security holes in applications. It is strongly discouraged; instead, applications should use more formal mechanism for interactions such asContentProvider
,BroadcastReceiver
, andService
. There are no guarantees that this access mode will remain on a file, such as when it goes through a backup and restore.
这篇关于具有MODE_PRIVATE,MODE_WORLD_READABLE,MODE_WORLD_WRITABLE的Android SharedPreferences的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!