PS:
/**
* File creation mode: allow all other applications to have read access to
* the created file.
*
* As of {@link android.os.Build.VERSION_CODES#N} attempting to use this
* mode will throw a {@link SecurityException}.
*
* @deprecated 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 {@link ContentProvider},
* {@link BroadcastReceiver}, and {@link android.app.Service}.
* There are no guarantees that this access mode will remain on
* a file, such as when it goes through a backup and restore.
* @see android.support.v4.content.FileProvider
* @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION
*/
@Deprecated
public static final int MODE_WORLD_READABLE = 0x0001;
若再尝试使用MODE_WORLD_READABLE 这种方式来建立SharePreference 会报SecurityException。
01-08 05:32:21.465 16339 16339 E AndroidRuntime: Caused by: java.lang.SecurityException: MODE_WORLD_READABLE no longer supported 01-08 05:32:21.465 16339 16339 E AndroidRuntime: at android.app.ContextImpl.checkMode(ContextImpl.java:2134) 01-08 05:32:21.465 16339 16339 E AndroidRuntime: at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:354) 01-08 05:32:21.465 16339 16339 E AndroidRuntime: at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:349) 01-08 05:32:21.465 16339 16339 E AndroidRuntime: at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:164) 01-08 05:32:21.465 16339 16339 E AndroidRuntime: at com.android.deskclock.Utils.getCESharedPreferences(Utils.java:778) 01-08 05:32:21.465 16339 16339 E AndroidRuntime: at com.android.deskclock.settings.DefaultAlarmToneDialog.(DefaultAlarmToneDialog.java:74)