Create a class that extends Application for your project (you have to declare it in the Manifest too), in the Application make a private static MyApplication app in the onCreate() of it assign it to the field app = this and make a public static MyApplication get() in it. When you need a Context you can use a MyApplication.get().
Create a class that extends Application for your project (you have to declare it in the Manifest too), in the Application make a private static MyApplication app in the onCreate() of it assign it to the field app = this; and make a public static MyApplication get() in it. When you need a Context you can use a MyApplication.get().
Worked great! Thanks for the help, it is truly appreciated! – Josh Nov 15 '10 at 2:08.
A few hints on Context: Get Context in you View via getContext() and pass it to getContentResolver(context). Use application-context approach as described here by @apps. Don't store context inside Activity or Views.
This leads to memory leaks.
Thank you for the advice. Through your advice and more reading I have learned how critical context handling is to memory management. – Josh Nov 15 '10 at 2:09.
I am currently trying to call a method from a utility class that will reference a new cursor created for this utility method. Unfortunately, my new class will not let me create the cursor without context. I have tried numerous ways of passing context from the calling activity, but get null pointer exceptions in most cases.
Using the above code it throws an error on getContentResolver(), and all attempts I've made to pass context have failed. I am fairly new to programming for Android, and don't fully understand the concept of contexts. Any help you guys could provide would be greatly appreciated!
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.