Thank you hackbod,  Steve Oldmeadow  and 6real for your response;

I've a question : can i acess to an object A stored in a Application
object from a simple class java?

because me i need to store an instance of a class A on starting of my
android application,later this instance A must be accessed by other
simple classes java included on my application.

Thanks for your responses.


On 25 juil, 07:47, 6real <[EMAIL PROTECTED]> wrote:
> I don't know exactly what will be your final choice but you maybe
> should think to implements a Singleton pattern :
>
> http://radio.weblogs.com/0122027/stories/2003/10/20/implementingTheSi...
>
> Personnaly I have a class named ConfigurationContext with only static
> variables that are stored, for persistence with the preferences
> mechanism (http://code.google.com/android/devel/data/preferences.html)
> and :
> in my first activity the class is loaded.
> Then all is accessed trough static attributs
> If one attribut is changed, then I saved the preferences.
>
> I hope it could help you but I only need to store simple object like
> strings/numbers or boolean.
>
> C.
>
> On Jul 25, 3:23 am, Steve Oldmeadow <[EMAIL PROTECTED]> wrote:
>
> > On Jul 24, 6:33 pm, solawe <[EMAIL PROTECTED]> wrote:
>
> > > Ok, thanks;
>
> > > But i dont know when i declare this variable? you think that i must
> > > declare it on the first activity of my application?
>
> > You could create an Application object and store it there.  Have a
> > look at android.app.Application.  It has an onCreate() that gets
> > called when the Application is created, before any Activities.  If it
> > is going to be accessed by Services you probably need to think about
> >threading issues.
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to