[android-developers] Re: Sharing SharedPreferences from two different processes

2013-05-15 Thread Gary Blakely
Michael,
Sorry but I don't understand your example.  You are specifying MODE_PRIVATE 
which is what I am doing...

SharedPreferences myMemory = getSharedPreferences(myMemory, MODE_PRIVATE);

Are you saying that if I specify | 0x4 (don't know what that means) that 
it will be the same as specifying MODE_MULTI_PROCESS?
btw, I'm targeting 2.33 gingerbread.
Gary

On Monday, May 13, 2013 11:59:32 PM UTC-7, Michael Schollmeyer wrote:

 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: Sharing SharedPreferences from two different processes

2013-05-15 Thread Michael Schollmeyer
Yes, appending | 0x4 will result in the same value.

Cheers, Michael
mictale.com/ms
--



On May 15, 2013, at 5:19 PM, Gary Blakely gdeanblak...@gmail.com wrote:

 Michael,
 Sorry but I don't understand your example.  You are specifying MODE_PRIVATE 
 which is what I am doing...
 
 SharedPreferences myMemory = getSharedPreferences(myMemory, MODE_PRIVATE);
 
 Are you saying that if I specify | 0x4 (don't know what that means) that it 
 will be the same as specifying MODE_MULTI_PROCESS?
 btw, I'm targeting 2.33 gingerbread.
 Gary
 
 On Monday, May 13, 2013 11:59:32 PM UTC-7, Michael Schollmeyer wrote:
 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 android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 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 a topic in the Google 
 Groups Android Developers group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/android-developers/4K-boEk41q8/unsubscribe?hl=en.
 To unsubscribe from this group and all its topics, send an email to 
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Sharing SharedPreferences from two different processes

2013-05-14 Thread Michael Schollmeyer
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: Sharing SharedPreferences from two different processes

2013-05-14 Thread Justin Anderson
On Tue, May 14, 2013 at 12:59 AM, Michael Schollmeyer
mich...@mictale.comwrote:

 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.


Wouldn't that also mean the app wouldn't run properly (not being able to
read shared preferences across processes)?


Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: Sharing SharedPreferences from two different processes

2013-05-14 Thread Justin Anderson
On Tue, May 14, 2013 at 12:39 PM, Justin Anderson magouyaw...@gmail.comwrote:

 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.


 Wouldn't that also mean the app wouldn't run properly (not being able to
 read shared preferences across processes)?


Let me clarify that question a bit...

Wouldn't that also mean the app wouldn't run properly (not being able to
read shared preferences across processes) *on versions of Android prior to
API 11*?

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: Sharing SharedPreferences from two different processes

2013-05-14 Thread Michael Schollmeyer
No, it works just fine on all API levels. You can write in one process and read 
in another one. The only thing that is not working across processes is change 
notifications.

Cheers, Michael
mictale.com/ms
--



On May 14, 2013, at 8:39 PM, Justin Anderson magouyaw...@gmail.com wrote:

 
 On Tue, May 14, 2013 at 12:59 AM, Michael Schollmeyer mich...@mictale.com 
 wrote:
 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. 
 
 
 Wouldn't that also mean the app wouldn't run properly (not being able to read 
 shared preferences across processes)?
 
 
 Thanks,
 Justin Anderson
 MagouyaWare Developer
 http://sites.google.com/site/magouyaware
 
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 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 a topic in the Google 
 Groups Android Developers group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/android-developers/4K-boEk41q8/unsubscribe?hl=en.
 To unsubscribe from this group and all its topics, send an email to 
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Sharing SharedPreferences from two different processes

2013-05-13 Thread Jonathan S
Context.MODE_MULTI_PROCESS

That is only available in API 11+ (3.0 and later)

On Monday, May 13, 2013 7:29:37 PM UTC-4, 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.