Programming Tips - Android: Using MODE_WORLD_READABLE when creating files can be risky, review carefully

Date: 2023jul25 OS: Android Language: Java Q. Android: Using MODE_WORLD_READABLE when creating files can be risky, review carefully A. The warning has a point. But if you have a good reason for making preferences world-readable... Change:
SharedPreferences pref = context.getSharedPreferences("pref", Context.MODE_WORLD_READABLE);
to:
final int mode = Context.MODE_WORLD_READABLE; SharedPreferences pref = context.getSharedPreferences("pref", mode);