Can SharedPreferences be shared between different Android apps?

As I checked in the API description for getSharedPreferences (String, int), the second attribute defines the accessibility mode and can take 0 or MODE_PRIVATE for the default operation MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE for managing permissions.

But there is this small note in the API description:

Note: this class (android.content.SharedPreferences) currently does not support the use of multiple processes. This will be added later.

In addition, in Mark L. Murphyโ€™s book, โ€œThe Beginning of Android 2,โ€ he mentioned:

(In the end, preferences may be for all applications, but which is not supported at the time of this letter)

I'm so confused! Does this mean that MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE from getSharedPrefrences are there, but DID NOT SUPPORT YET at the last API level ???

Thanks! Migan

+8
android preferences
source share
1 answer

My book reference is based on this comment.

Also, creating any MODE_WORLD_READABLE file or (even worse) MODE_WORLD_WRITEABLE is a bad idea. You lose hope of security.

If you want to share data between two applications, there are many solutions, such as:

  • AIDL open API service
  • with an API being opened via commands sent via startService() and responses sent via Messenger or createPendingResult() PendingIntent or something
  • content provider
  • Broadcast Intents

All of them allow you to define permissions for integration and allow you to control the granularity of access.

+7
source share

All Articles