1

I'm using PreferenceActivity to let Android handle some persistent key/value pairs for my app.

According to the Android Preference docs :

Note that saved preferences are accessible only to the application that created them.

However, when further researching the security and permissions aspect of preferences, I come across questions like this one:

Android: Retrieving shared preferences of other application

where some users are saying that preferences may be made world readable and world writeable and that they are successfully able to access them across applications.

So my question is:

Are preferences inalienably inaccessible across applications or do I have to take precautions to make them so?

Note: I'm am not trying to use preferences to share data among apps. Quite the opposite - I want to know that any preferences my users set are secure from inspection/alteration by other apps.

Community
  • 1
  • 1
  • http://stackoverflow.com/questions/4787785/can-sharedpreferences-be-shared-among-different-android-applications see this answer – Shruti Mar 02 '12 at 10:00

2 Answers2

2

From the above answers and comments, it looks to me like the android developer docs on this subject are a bit misleading.

I even found another place where the developer docs state explicitly that settings are not accessible across apps:

(Note that it is not possible to share settings data across application packages -- for that you will need a content provider.)

Reference to the above quote it here: http://developer.android.com/reference/android/app/Activity.html#SavingPersistentState

But the responses from @shruti and @raman-bhatia (thanks guys!) both support the fact that settings can be configured to be shareable across apps, as does the SO query I referenced in the question.

The clincher was finding this SO query: Difference between getDefaultSharedPreferences and getSharedPreferences which shows how it the default shared preferences file is initially configured as private.

Thanks to all. The answer is that the docs are misleading in that preferences can be coerced to being shareable across apps, but that PreferenceActivity will by default create a secure shared preferences file visible only to the components of the app from which originated.

Community
  • 1
  • 1
0

There are modes associated with the shared preferences that you get to define when you create them. For example, you can make them as "World Readable" or "World Writable" if you want the rest of the applications on your device to be aware of them. You can thus use your own flags to adjust the transparency of the shared preferences that you create

brut3f0rc3
  • 1,173
  • 4
  • 13
  • 19