I do something like this:
prefs = context.getSharedPreferences(context.getPackageName() +
"_preferences", Context.MODE_PRIVATE | 0x4); // Context.MODE_MULTI_PROCESS
Which also compiles in earlier API levels. The additional flag does no harm
in pre-level-11 runtimes.
Also notice that OnSharedPreferenceChangeListener will not trigger across
processes.
On Tuesday, May 14, 2013 1:29:37 AM UTC+2, Gary Blakely wrote:
>
> My app originally had an activity and a service running in the same
> process. When I first wrote it I specified sharedPreferences with
> MODE_PRIVATE. The app has grown, and for reasons beyond the scope of this
> post, I now need to run my service in a different process.
>
> I found I can do this by specifying a name starting with a colon in the
> android:process statement in my manifest file.
>
> However now my activity and my service are no longer reading the same
> sharedPreferences. Researching this problem I see many reccommendations to
> use MODE_MULTI_PROCESS. But I cannot figure out how to spedify it.
>
> SharedPreferences myMemory = getSharedPreferences("myMemory",
> MODE_MULTI_PROCESS);
>
> This does not work because Eclipse can't find MODE_MULTI_PROCESS like it
> can find MODE_PRIVATE or MODE_WORLD_READABLE. I don't know where the ENUM
> for MODE_MULTI_PROCESS is.
>
> So, how can I specify MODE_MULTI_PROCESS ??
> thanks, Gary
>
>
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.