Sharing data between android apps on the same device by same publisher where no one app is host

639 Views Asked by At

I have looked through so many similar stackoverflow posts but none of them seem to solve my specific problem. I want something like the iOS Shared Keychain storage, that any app signed by the same certificate can read and write to. The only answer everywhere is using Content Providers, but unfortunately with Content Providers, it seems that one app needs to be the host, and the other apps are the clients. I seek more of a peer-to-peer style of data sharing, where I have many apps but my users may have perhaps downloaded only a small subset of them (but more than one). There is data that will be shared between those apps, and any of the apps may be uninstalled at any time, and more apps by the same vendor might get installed at any time. In any case, the data should persist as long as there is at least one app by that vendor. When all apps are uninstalled, only then should that data be destroyed. These apps do have a common package name, but a unique application name.

Any suggestions?

1

There are 1 best solutions below

0
On

You can use ContentProviders to share files or you can use a Service with Android Interface Definition Language (AIDL).

For Android 11 (API level 30) you may also need to specify a query with the package of the app you want to interact with:

<manifest package="com.example.app">
  <queries>
    <!-- Specific apps you interact with, eg: -->
    <package android:name="com.example.service" />
  </queries>
  ...
</manifest>