0

We can share data between enterprise applications in iOS using AppGroup feature. How we can achieve the same functionality in android.

I have tried using sharedpreferences but MULTI PROCESS MODE is deprecated in API level 23 or higher.

Suggestions..

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • Use any form of IPC, such as a `ContentProvider` or a bound `Service`. Things get messy if the apps can be installed in any order, though. – CommonsWare Jan 28 '19 at 12:40
  • @CommonsWare: I am trying to seamlessly access a string value stored/modified in either of the applicaion(App1 or App2). For example if user logs into one applications and I have his username saved in the App1, if I open App2 I should be able to access the username string. I think you get what I want to achieve? – Mobile Developer iOS Android Jan 28 '19 at 12:55
  • Android does not support that scenario especially well. App1 can detect if App2 is installed and ask it for the username string, should App1 need it, using any form of IPC. App2 can do the same thing. The actual storage, though, is on a per-app basis. – CommonsWare Jan 28 '19 at 13:11
  • let me phrase is like this, Is it possible for two apps to write data on same sharedprefrences? – Mobile Developer iOS Android Jan 30 '19 at 12:59
  • No, sorry, that is not supported. – CommonsWare Jan 30 '19 at 13:41
  • what about using sharedUserId with package createPackageContent using same certificates? – Mobile Developer iOS Android Jan 30 '19 at 13:45
  • `SharedPreferences` do not support multiple processes (they never did; the deprecation was merely a formality). While presumably you would be able to access the other app's `SharedPreferences` that way, running apps will not see the changes from other running apps and will overwrite those changes. Plus, if either of these apps have already shipped, you cannot change the `android:sharedUserId` value without locking all existing users out of all existing files. – CommonsWare Jan 30 '19 at 13:57
  • check the 'android:sharedUserId' option – dogood Feb 01 '19 at 07:16

1 Answers1

0

you have several options - from simple to more advanced

  1. Sharing simple data
  2. Content provider
  3. AIDL - Base on your comments, i think this option would meet your requirements. you will need to have bi-directional communication.
  4. Use 'android:sharedUserId' and sign both your apps with the same private key and same alias - would be more secure approach

The name of a Linux user ID that will be shared with other apps. By default, Android assigns each app its own unique user ID. However, if this attribute is set to the same value for two or more apps, they will all share the same ID — provided that their certificate sets are identical. Apps with the same user ID can access each other's data and, if desired, run in the same process.

  1. socket connection - I wouldn't recommend it

you should also consider security risks.

dogood
  • 331
  • 2
  • 5