Android SharedPreferences with MODE_PRIVATE,MODE_WORLD_READABLE,MODE_WORLD_WRITABLE

android

Solution

`getSharedPreferences(String name, int mode)` is explained here

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).

MODE_WORLD_READABLE: File creation mode: allow all other applications to have read access to the created file.

MODE_WORLD_WRITEABLE : File creation mode: allow all other applications to have write access to the created file.

More info here

Edit As of API 17, the `MODE_WORLD_READABLE` and `MODE_WORLD_WRITEABLE` are deprecated:

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 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.

Problem

`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); ``` What does it signify to make this preferences `MODE_WORLD_READABLE`, `MODE_WORLD_WRITABLE` or `MODE_PRIVATE`?

Original source