我有一个应用程序已经上市,我们称它为“旧应用程序”。我想创建一个“新应用”,与我决定使用 SharedID 的旧应用共享数据。
我更改了新应用的 list ,添加了以下行:
android:sharedUserId="com.myname.myoldapp"
其中 com.myname.myoldapp 是旧应用程序包的名称。但它不起作用。
如何使用新应用程序访问旧应用程序数据? 更改旧应用的 userId 以匹配新应用的 shareduserid 显然不是一种选择,因为旧应用已经在线并且所有更新它的用户都会丢失他们的个人数据。
PS:证书是一样的。
谢谢。
最佳答案
I have an app that already is on the market, let's call it "old app". I would like to create a "new app" that shares the data with the old one app I decided to do it using a SharedID.
如果不破坏所有现有安装,那将不再可能。
I changed the manifest of the NEW app adding the following line: android:sharedUserId="com.myname.myoldapp" Where com.myname.myoldapp is the name of the old app package. But it does not work.
如果您阅读 the documentation on android:sharedUserId
,你会看到你被告知:“但是,如果两个或多个应用程序将此属性设置为相同的值,它们将共享相同的 ID”(强调我的)。由于您的旧应用没有 android:sharedUserId
,因此您无法将新应用设置为旧应用的 android:sharedUserId
值。
How can I access with the new app to the old app data?
使用服务
。或者 ContentProvider
。或 Android 支持的任何其他形式的 IPC。旧应用程序需要公开一个基于 IPC 的 API,新应用程序可以使用它来访问旧应用程序的数据。您可以使用自定义签名
级别的权限来将对这些 API 的访问限制为您的应用。
关于android - 使用 sharedUserId 访问另一个应用程序的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15547755/