SharedPreferences in BroadcastReceiver seems to not update?

I had the same problem and after struggling for hours to solve it, I finally found the issue causing it. In your AndroidManifest you probably have something like that:

<receiver android:name="AlarmReceiver" android:process=":remote" />

The last attribute (process:remote) cause the receiver to run on a different/new process when it is called. But SharedPreferences is NOT supported between different processes.

So what I did is to remove that last attribute from the manifest. The implication is that the code will now run on the main thread – but if you only have a few lines to show a notification then that shouldn’t be a problem. Another way is to call a service to run the long operation.

Leave a Comment