gpt4 book ai didi

android - 如何在android中的两个或多个应用程序之间安全地共享数据?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:23:38 26 4
gpt4 key购买 nike

我正在为企业环境制作一个应用程序框架,它涉及两个或多个应用程序之间从设备内存中共享数据。此数据需要存储在设备上,并且只有少数应用程序可以访问(可以通过安装它们所用的证书来识别)。此外,它需要以安全的方式存储,以防止其他第三方应用程序访问。哪个是实现此功能的最佳方式?

我已经阅读了关于 ContentProviders and ContentResolvers 的内容据我了解,这只会促进这一过程。数据的实际存储才是更重要的。我也研究了Keychain API Android 这似乎是最接近我需要实现的目标。

有没有办法将 ContentProvidersContentResolvers 与 Keychain API 集成?这是这样做的正确方法吗?如果不是,实现相同目标的最佳方法是什么?此外,我还没有找到好的代码示例 来完全理解Keychain API 的功能。 请帮忙!

编辑:
我也看过 Keystore API .这在内部使用 Keychain API,为了在应用程序之间共享数据,应该使用 Keychain。尽管我无法找到相同的代码示例或有关如何使用 Keychain API 的详细文档或 API 指南。我正在寻找一个相当于 iOS Keychain 的安卓系统.

称为 managed profiles 的东西在 Android 5 中也被引入。这是实现我想要做的事情的正确方法吗?

最佳答案

您必须使用相同的 sharedUserId 声明您的应用程序,例如:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mydomains.myapp"
android:sharedUserId="com.mydomains.shared.user.id"
android:sharedUserLabel="@string/appName">

在这种情况下,存储在两个应用程序私有(private)存储中的所有数据将相互可用(假设它们使用相同的签名签名)

如阅读手册:

sharedUserId: The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that they are also signed by the same certificate. Application with the same user ID can access each other's data and, if desired, run in the same process.

关于android - 如何在android中的两个或多个应用程序之间安全地共享数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36302597/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com