androidmultiprocessingandroid-sharedpreferences

SharedPreferences in Android not getting recently updated values across multiple running processes


Description: I have two apps App1 and App2. I am using App1 to store some key value pair in SharedPreferences. I am accessing the same key value in App2.

I launch app1. Create a key with value abc. Now I keep app1 in background and launch App2 and I change the key value to def.

When I launch app1 from background to foreground and access the key value. Value retrieved is abc instead of updated value def. If I kill App2 from background and relaunch it then only updated value is getting reflected


Solution

  • SharedPreferences has never supported multiple processes, let alone multiple apps. The documentation explicitly states:

    Note: This class does not support use across multiple processes.