[android-developers] Re: Recommended uses of a class extending android.app.Application

2009-09-12 Thread Gustav Mauer
I store my application config data in preferences: http://developer.android.com/guide/topics/data/data-storage.html#pref And have a singleton class to read and write (aka wrap) them. That way it is also maintained even if the application is killed. On Sep 11, 8:21 pm, Tom Gibara

[android-developers] Re: Recommended uses of a class extending android.app.Application

2009-09-11 Thread Mark Murphy
Android Development wrote: The docs here: http://developer.android.com/reference/android/app/Application.html say that, if the application needs to maintain global state, it should do it here. On the other hand, Ms. Hackborn has indicated that she thinks the Application object is not that

[android-developers] Re: Recommended uses of a class extending android.app.Application

2009-09-11 Thread Tom Gibara
I think it's more accurate to say *you may choose* to maintain global state by extending Application. It's my preferred approach, though it's important to to instantiate global state lazily wherever it's sensible to do so. I describe my default approach here:

[android-developers] Re: Recommended uses of a class extending android.app.Application

2009-09-11 Thread Android Development
Thanks for the replies. The data is hidden from the human user and is totally consumed by the application. Its a small file..some 4-5 attributes only. I am also somewhat inclined towards using a static singleton option. On Fri, Sep 11, 2009 at 8:43 PM, Tom Gibara m...@tomgibara.com wrote:

[android-developers] Re: Recommended uses of a class extending android.app.Application

2009-09-11 Thread Dianne Hackborn
On Fri, Sep 11, 2009 at 8:10 AM, Mark Murphy mmur...@commonsware.comwrote: The four main options I have used are: 1. Custom application class, like you are proposing 2. Static data (e.g., singleton class instance holding your configuration) 3. A service 4. Shared preferences Best is

[android-developers] Re: Recommended uses of a class extending android.app.Application

2009-09-11 Thread Tom Gibara
I hesitate to raise a word against any of Dianne's advice (ever) - and it clearly depends on the nature of your application. But what I find with my code is that most of the global state I want to keep depends on a Context. For example, anything that loads resources, or anything that needs to