可以共享preferences在不同的Andr​​oid应用程序共享? [英] Can SharedPreferences be shared among different Android applications?

查看:139
本文介绍了可以共享preferences在不同的Andr​​oid应用程序共享?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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()并通过使者或<$发送的响应发送的命令暴露C $ C> 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.

这篇关于可以共享preferences在不同的Andr​​oid应用程序共享?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆