Skip to content Skip to sidebar Skip to footer

Managing Sharedpreferences In Both Preferenceactivity And Service Within Same App

I'm building an app with a PreferenceActivity and a Service (running in its own remote process due to android:process=':remote' flag) and both need to access programmatically the S

Solution 1:

You only need MODE_MULTI_PROCESS if you are accessing the preferences from different processes. If you just have different activities that are using the shared prefs then you don't need MODE_MULTI_PROCESS.

You mention that you have a service. As long as the service is running in the same process as the activities you still don't need MODE_MULTI_PROCESS. The service will run by default in the same process unless you have specified android:process="..." in the <service> tag in the manifest.

Solution 2:

The other big advantage: garbage collects in a busy service don't interfere with animations in the user interface.

Post a Comment for "Managing Sharedpreferences In Both Preferenceactivity And Service Within Same App"