1. Are you ready for the Galaxy S20? Here is everything we know so far!

SharedPrefrences Modes

Discussion in 'Android Development' started by ydn_dev, May 20, 2011.

  1. ydn_dev

    ydn_dev Lurker
    Thread Starter


    I'm a new Android developer. I'm using SharedPreferences to store some application settings. While I understand most of the usage scenarios and related APIs, MODES are still a mystery for me:
    1) Most of the books that I have read say that SharedPreferences cannot be shared across applications. Yet, there are modes:

    • MODE_WORLD_READABLE(allows all other applications to have read access to the created file).
    • MODE_WORLD_WRITABLE (allows all other applications to have write access to the created file)
    that control the OS level permissions set for the underlying xml file. But this also seems to suggest that sharing across applications is possible. So can I create a SharedPreferences object in APP-1 which refers to a SharedPreferences file created by APP-2. If so, how? Or will I need to use the I/O APIs to read /write preferences created by a different application. If io is the way to go, will changes made through I/O APIs generate callbacks on any registered SharedPreferencesChangeLsiteners in APP-1.

    2) MODE_MULTI_PROCESS looks like a feature to be added in the future. Am I right? Because the api documention for class SharedPreferences says: "currently this class does not support use across multiple processes. This will be added later".

    1. Download the Forums for Android™ app!



Share This Page