Are two packages in one APK possible?

I am trying to implement this wonderful technique about common preferences in two different applications, while MODE_PRIVATE.

My problem is that the first application cannot assume that the first application is installed (and vice versa) and so:

 Context c = createPackageContext("com.app.first", MODE_PRIVATE);

Must be replaced by:

 Context c = createPackageContext("com.app.shared", MODE_PRIVATE);

But for this you need to add that com.app.sharedfor real, what translates to the second APK?

In other words, there is only one AndroidManifest.xml for the APK and only one <manifest package= > for the manifest file. Therefore, only one actual package on the APK?

I do not want to use 2 APKs for each application, I only need one APK for each application.

Is there any way to achieve this?

+1
1

, MODE_PRIVATE.

, - , . android:sharedUserId . , .

, , , ... . A App B A, , , B .

, APK?

.

2 APK , APK .

APK, .

+2

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


All Articles