2

I'm building a shared library that can be shared in many applications

I need global variable that all apps using this library can write and read the variable.

I check the solutions:

1) shard preference - irrelevant, because I do not have a standalone application.

2) content Provider- irrelevant, because I do not have a standalone application.

3) SQLite DB - irrelevant, because I do not have a standalone application.

4) file in SD card - problem if there is no SD card.

Does anyone have an idea how to do it?

Rachel B
  • 33
  • 6
  • http://stackoverflow.com/questions/5745243/data-sharing-between-two-applications Possible dupplicite question – Martin Perry Aug 25 '13 at 09:41
  • Maybe it would be helpful, if you'd provide a little bit more context. What kind of data do you need to share across application boundaries? What exactly makes those solutions listed "irrelevant"? – Dirk Aug 25 '13 at 22:36
  • I need flag (Boolean variable) to share across application boundaries, – Rachel B Aug 26 '13 at 06:26

1 Answers1

1

I personally am not 100% sure if you can or cannot use sharedPreferences between two applications, however here is a post I found that guides you on how to do it: http://thedevelopersinfo.com/2009/11/25/getting-sharedpreferences-from-other-application-in-android/

Here is another post that may help you: SharedPreferences between arbitrary applications

Community
  • 1
  • 1
Luke Taylor
  • 9,481
  • 13
  • 41
  • 73
  • Thank you very much!! To use a shared preference of another application I need to know the package name context.createPackageContext(package name); but I don't know, I cannot be sure that one of the apps (with specific package name) that use shared library is installed on the phone. – Rachel B Aug 25 '13 at 18:43
  • Also starting from Android 7 (API 24) you aren't able to access SharedPreferences of another app. – researcher Sep 05 '19 at 14:09