android7.0对于SharedPreferences设置模式的限制
错误信息:
03-28 10:16:12.701 830 932 E AndroidRuntime: FATAL EXCEPTION: Thread-9
03-28 10:16:12.701 830 932 E AndroidRuntime: Process: com.solomo.azt, PID: 830
03-28 10:16:12.701 830 932 E AndroidRuntime: java.lang.SecurityException: MODE_WORLD_READABLE no longer supported
03-28 10:16:12.701 830 932 E AndroidRuntime: at android.app.ContextImpl.checkMode(ContextImpl.java:2137)
03-28 10:16:12.701 830 932 E AndroidRuntime: at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:354)
03-28 10:16:12.701 830 932 E AndroidRuntime: at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:349)
03-28 10:16:12.701 830 932 E AndroidRuntime: at com.baidu.android.pushservice.util.p.x(Unknown Source)
03-28 10:16:12.701 830 932 E AndroidRuntime: at com.baidu.android.pushservice.util.p.v(Unknown Source)
03-28 10:16:12.701 830 932 E AndroidRuntime: at com.baidu.android.pushservice.util.p.m(Unknown Source)
03-28 10:16:12.701 830 932 E AndroidRuntime: at com.baidu.android.pushservice.util.p.l(Unknown Source)
03-28 10:16:12.701 830 932 E AndroidRuntime: at com.baidu.android.pushservice.internal.PushManager.startWork(Unknown Source)
03-28 10:16:12.701 830 932 E AndroidRuntime: at com.baidu.android.pushservice.apiproxy.BridgePushManager.startWork(Unknown Source)
03-28 10:16:12.701 830 932 E AndroidRuntime: at com.baidu.android.pushservice.PushManager$40.run(Unknown Source)
03-28 10:16:12.701 830 932 E AndroidRuntime: at com.baidu.android.pushservice.LoadExecutor$1.run(Unknown Source)
03-28 10:16:12.701 3691 17138 I ActivityManager: handleApplicationCrash callcom.solomo.azt
关于此限制的说明:
https://developer.android.com/reference/android/content/Context.html#MODE_WORLD_READABLE
MODE_WORLD_READABLE
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 as ContentProvider
, BroadcastReceiver
, and Service
. There are no guarantees that this access mode will remain on a file, such as when it goes through a backup and restore.
File creation mode: allow all other applications to have read access to the created file.
As of N attempting to use this mode will throw a SecurityException
.