[android-developers] Re: Share data between activities queston

2009-01-09 Thread Mark Murphy

EvgenyV wrote:
 Hi!
 
 What is the best way to share data between different activities?

I suspect we will be better able to answer your question if you can give
us more context. For example, how much data? One bit? A simple
structure? Something the size of a small database? All of Wikipedia?

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Published!

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[android-developers] Re: Share data between activities queston

2009-01-09 Thread Evgeny V
Something really simple like initial settings of the application which
stored in one module but read from other module(s). For example number of
last active tab, some selected index from spinner etc.

Thanks

On Fri, Jan 9, 2009 at 9:30 PM, Mark Murphy mmur...@commonsware.com wrote:


 EvgenyV wrote:
  Hi!
 
  What is the best way to share data between different activities?

 I suspect we will be better able to answer your question if you can give
 us more context. For example, how much data? One bit? A simple
 structure? Something the size of a small database? All of Wikipedia?

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 2.0 Published!

 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[android-developers] Re: Share data between activities queston

2009-01-09 Thread Mark Murphy

Evgeny V wrote:
 Something really simple like initial settings of the application which
 stored in one module but read from other module(s). For example number
 of last active tab, some selected index from spinner etc.

If they are things that should also persist across application runs, you
might as well use SharedPreferences.

If they are things that do not need to be persisted, and your
application is all in one process (the default), you could just use
static methods to access shared values.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Published!

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[android-developers] Re: Share data between activities queston

2009-01-09 Thread Evgeny V
SharedPreferences is private data per activity. I tried to store persist
data from activity A but can't read it from activity B.
Missed I something?

On Fri, Jan 9, 2009 at 9:42 PM, Mark Murphy mmur...@commonsware.com wrote:


 Evgeny V wrote:
  Something really simple like initial settings of the application which
  stored in one module but read from other module(s). For example number
  of last active tab, some selected index from spinner etc.

 If they are things that should also persist across application runs, you
 might as well use SharedPreferences.

 If they are things that do not need to be persisted, and your
 application is all in one process (the default), you could just use
 static methods to access shared values.

 --
  Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 2.0 Published!

 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[android-developers] Re: Share data between activities queston

2009-01-09 Thread Evgeny V
The data is persist. I need to serialize it to disk to allow loading after
app restarted.

On Fri, Jan 9, 2009 at 9:56 PM, hmmm akul...@mail.ru wrote:


 Intent.putExtra() Intent.getExtra() will, probably, do

 - Original Message -
 From: EvgenyV evgen...@gmail.com
 To: Android Developers android-developers@googlegroups.com
 Sent: Friday, January 09, 2009 10:27 PM
 Subject: [android-developers] Share data between activities queston


 
  Hi!
 
  What is the best way to share data between different activities?
 
  Thanks in advance,
  Evgeny
  

 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[android-developers] Re: Share data between activities queston

2009-01-09 Thread Mark Murphy

Evgeny V wrote:
 SharedPreferences is private data per activity. I tried to store persist
 data from activity A but can't read it from activity B.
 Missed I something?

SharedPreferences are not private per activity.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android Training in Sweden -- http://www.sotrium.com/training.php

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[android-developers] Re: Share data between activities queston

2009-01-09 Thread Evgeny V
Ok! I go my mistake.
Used getPreferences() instead getSharedPreferences()

Thank you very much!


On Fri, Jan 9, 2009 at 10:16 PM, Mark Murphy mmur...@commonsware.comwrote:


 Evgeny V wrote:
  SharedPreferences is private data per activity. I tried to store persist
  data from activity A but can't read it from activity B.
  Missed I something?

 SharedPreferences are not private per activity.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 Android Training in Sweden -- http://www.sotrium.com/training.php

 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[android-developers] Re: Share data between activities queston

2009-01-09 Thread Dianne Hackborn
You just want the version of getSharedPreferences() that takes a String.

On Fri, Jan 9, 2009 at 12:57 PM, Evgeny V evgen...@gmail.com wrote:

 Ok! I go my mistake.
 Used getPreferences() instead getSharedPreferences()

 Thank you very much!


 On Fri, Jan 9, 2009 at 10:16 PM, Mark Murphy mmur...@commonsware.comwrote:


 Evgeny V wrote:
  SharedPreferences is private data per activity. I tried to store persist
  data from activity A but can't read it from activity B.
  Missed I something?

 SharedPreferences are not private per activity.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 Android Training in Sweden -- http://www.sotrium.com/training.php
   



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---