Similar posts that do not have the answer i'm looking for.
Using Application context everywhere?
http://developer.android.com/reference/android/app/Application.html
Static way to get 'Context' on Android?
What's the difference between the various methods to get a Context?
Description of problem:
I have a set of utility classes, some of which write files. Others may use databases, etc. The point being that more than one of my utility classes need Contexts. One trivial example is reading from the strings.xml via context.getString(r.strings.id).
I think in most cases I'd like to avoid singletons. Unless absolutely necessary i'll go with a singleton. This has been solved and posted on one of the links. I personally consider them an ati-pattern. Just a personal choice. I understand that your application context by definition is a singleton object. There is only one application for each app-context. I am open to go with the option described above if it is the only way.
Question:
How can my utility classes get acces to my app context such that I can simply do new MyContext(). This context needs to have a reference to the app resources. I think this is called applicationContext() when called from an activity. Ideally this would be a cheap operation.
Thank you.
Edit:(clarification) I'm writing a service that an application is going to bind itself to. I think this should not affect the answer. Thanks again.