Get the Application Context In Fragment In Android?

后端 未结 8 1443
無奈伤痛
無奈伤痛 2020-12-02 08:36

I have stored some data to a Global Class By using the Application Context In One Activity. Later I have to Retrieve those values in A Fragment. I have done something like t

相关标签:
8条回答
  • 2020-12-02 09:38

    Use

    getActivity().getApplicationContext()

    to obtain the context in any fragment

    0 讨论(0)
  • 2020-12-02 09:41

    Try to use getActivity(); This will solve your problem.

    0 讨论(0)
提交回复
热议问题