Using static variables in Android

Posted by michael on Stack Overflow See other posts from Stack Overflow or by michael
Published on 2010-03-19T08:51:12Z Indexed on 2010/03/19 17:41 UTC
Read the original article Hit count: 232

Filed under:
|
|

Hi,

In android, are using static variables a recommended practice? E.g, implementing a Singleton pattern in Java, I usually do:

private static A the_instance;
public static A getInstance() {
    if (the_instance == null) {
       the_instance = new A();
    }
    return the_instance;
}

Also, when does this get cleaned up by the Android JVM?

Thank you.

© Stack Overflow or respective owner

Related posts about android

Related posts about java