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 useful and has recommended simple static data members as an alternative. > Suppose, i need to load some configurable data from a config file (to be > used later at runtime by my application's various components). This data > will be valid throughout the application's lifecycle (until it dies). > > So, is it the best approach to extend this class and override the > onCreate ( ) method to load config data from a data source ? 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 somewhat subjective -- I certainly do not have a definitive "always use X" recommendation. If it is a simple configuration file, I'd be inclined to go with the static singleton class instance if the configuration is not user-managed, SharedPreferences otherwise. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Need help for your Android OSS project? http://wiki.andmob.org/hado --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---