How to call method from another class without passing context?

前端 未结 2 1963
一个人的身影
一个人的身影 2020-12-19 18:52

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 cr

2条回答
  •  悲哀的现实
    2020-12-19 19:41

    A few hints on Context:

    1. Get Context in you View via getContext() and pass it to getContentResolver(context).

    2. Use application-context approach as described here by @apps.

    3. Don't store context inside Activity or Views. This leads to memory leaks.

提交回复
热议问题