I have got a question regarding the usage of context in a fragment. My problem is that I always get a NullpointerException. Here is what i do:
Create a class that extends the SherlockFragment. In that class I have an instance of another Helper class:
public class Fragment extends SherlockFragment {
private Helper helper = new Helper(this.getActivity());
// More code ...
}
Here is an extract of the other Helper class:
public class Helper {
public Helper(Context context) {
this.context = context;
}
// More code ...
}
Everytime I call context.someMethod
(e.g. context.getResources() ) I get a NullPointerException. Why is that?