可以共享preferences在不同的Andr​​oid应用程序共享?应用程序、不同、preferences、oid

由网友(眉间万般柔情)分享简介:我在API的说明getShared preferences(字符串,INT)检查,第二属性定义可访问模式,可以采取0或MODE_PRIVATE的默认操作,MODE_WORLD_READABLE和MODE_WORLD_WRITEABLE控制权限。As I checked in APIs description for...

我在API的说明getShared preferences(字符串,INT)检查,第二属性定义可访问模式,可以采取0或MODE_PRIVATE的默认操作,MODE_WORLD_READABLE和MODE_WORLD_WRITEABLE控制权限。

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 operation, MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE to control permissions.

但是,这种小记在API说明:

But there is this small note in API description:

注:目前这一类   (android.content.Shared preferences)   不支持跨多个应用   流程。这将在以后添加。

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

此外,在马克L.墨菲的书开头的Andr​​oid 2,他提到:

Moreover in Mark L. Murphy book "beginning Android 2" he mentioned:

(最终,preferences可能   共享跨应用程序,但   不支持作为时间   写这篇文章的)

(Eventually, preferences might be shareable across applications, but that is not supported as of the time of this writing)

我太糊涂了!这是否意味着MODE_WORLD_READABLE getShared prefrences的MODE_WORLD_WRITEABLE并且有,但尚不支持最新的API级别???

Im so confused! does this mean that MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE of getSharedPrefrences is there but NOT SUPPORTED YET in latest API level???

谢谢! 米泔

推荐答案

我的书引用基于这样评论。

My book reference is based upon that comment.

此外,使 MODE_WORLD_READABLE 的任何文件或(差) MODE_WORLD_WRITEABLE 是一个坏主意。你失去了安全的希望。

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:

与AIDL暴露的API服务 在使用API​​服务威盛 startService()并通过使者或 createPendingResult() PendingIntent 什么 内容提供商 广播意图 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.

阅读全文

相关推荐

最新文章