Can SharedPreferences be shared among different Android applications?

前端 未结 1 1481
眼角桃花
眼角桃花 2020-12-06 12:42

As I checked in APIs description for getSharedPreferences(String, int),Second attribute is defining accessibility mode and can take 0 or MODE_PRIVATE for the default operati

相关标签:
1条回答
  • 2020-12-06 13:01

    My book reference is based upon that comment.

    Moreover, making any file MODE_WORLD_READABLE or (worse) MODE_WORLD_WRITEABLE is a bad idea. You lose any hope of security.

    If you wish to share data between two applications, there are a myriad of solutions, such as:

    • service with an API exposed by AIDL
    • service with an API exposed via commands sent via startService() and responses sent via a Messenger or createPendingResult() PendingIntent or something
    • content provider
    • broadcast Intents

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

    0 讨论(0)
提交回复
热议问题