How can getContentResolver() be called in Android?


I want to know the context in which getContentResolver() is called?

I have a scenario like this:
I have an activity A that calls a method myFunc() of class B which is not an activity.
So, in class B I have to use getContentResolver(). I directly called getContentResolver(). It was showing error. Then I called myFunc(Acitivy act) from the activity and called act.getContentResolver() which solved my problem. Is this the only way to call getContentResolver(), which means it can be used in context with activity or can be used alone.

12/27/2011 4:34:19 PM

Accepted Answer

getContentResolver() is method of class android.content.Context, so to call it you definitely need an instance of Context ( Activity or Service for example).

9/20/2010 12:39:57 PM

You can use like this:


with the proper context.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow