Fields
static
tied to the Class
instance as a whole, which in turn is tied to the ClassLoader
that loaded the class. the_instance
will be unloaded when the entire ClassLoader
is restored. I am 90% sure that this happens when Android destroys the application (and not when it goes into the background or pauses, but completely shuts down.)
So, think of it as life while your application is running. Is Singleton a good idea? People have different views. I think it's good to use it appropriately. I donβt think the answer will change much on Android. Memory usage is not a problem in itself; if you need to load a bunch of material in memory, this is either a problem or it doesn't exist, regardless of whether you encapsulate the data in Singleton.
Sean Owen Mar 19 '10 at 9:30 2010-03-19 09:30
source share