To get the context in a fragmented use getActivity(), which renders the activity associated with a fragment.
The activity is a context (since Activity continues Context).
Example:
public class Animal extends Fragment {
Context thiscontext;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
thiscontext = container.getContext();
Click here to read more about getActivity().