How to securely exchange data between two or more applications in Android?

I am creating an application infrastructure for an enterprise environment that involves the exchange of data between two or more applications from the deviceโ€™s memory . This data should be stored on the device and available only to a few applications (which can be identified using the certificates used to install them) . In addition, it must be kept safe so that it is not accessible to other third-party applications. What is the best way to implement this functionality?

I read about ContentProviders and ContentResolvers , which, as far as I know, makes this process easier. Important is the actual storage of data. I also looked at the Keychain API for Android, which seems to be closest to what I need to achieve.

Is there a way to integrate ContentProviders and ContentResolvers with Keychain APIs? Is this the right way to do this? If not, what is the best way to achieve the same ? In addition, I could not find good code examples to fully understand the functioning of the Keychain API. Please, help!

Edit:
I also reviewed the Keystore API . This internally uses the Keychain API, and to exchange data between applications, you should use Keychain. Although I could not find code samples for the same or detailed documentation or API guide on how to use the Keychain API. I am looking for the android equivalent of iOS Keychain .

Android 5 introduced something known as control profiles . Is this the right way to achieve what I'm trying to do?

+5
source share
1 answer

You must declare your applications with the same sharedUserId , for example:

 <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"> 

In this case, all data stored in the private storage of both applications will be available to each other (it is assumed that they signed the same signature)

As an instruction manual:

sharedUserId: name of the Linux user identifier to 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, all of them will have the same identifier - provided that they are also signed by the same certificate. An application with the same user ID can access other data and, if desired, run in the same process.

+1
source

Source: https://habr.com/ru/post/1246046/


All Articles