Singleton wrapper for Context

Posted by kpdvx on Stack Overflow See other posts from Stack Overflow or by kpdvx
Published on 2010-05-03T18:00:45Z Indexed on 2010/05/03 18:08 UTC
Read the original article Hit count: 174

Filed under:

I'm considering creating a singleton wrapper for a Context so my model objects, if necessary, can open and read from a database connection. My model objects do not have access to a Context, and I'd like to avoid needing to pass a reference to a Context from object to object.

I was planning to place into this singleton a reference to the Context returned by Application.getApplicationContext(). This singleton object would be initialized in my custom Application instance before anything else would need to or have a chance to use it.

Can anyone think of a reason to not do this?

© Stack Overflow or respective owner

Related posts about android