Using getContentResolver in the BroadcastReceiver Advanced Class

I need to use the getContentResolver method in a class that extends BroadcastReceiver, and I found that getContentResolver can only be used in a class that extends Activity. I am trying to make a static method in a class that extends activity, but I cannot use getContentResolver in a static method. I also tried a non-static method, but when I start the application, I get an error message. How can i do Thank!

+3
source share
2 answers

In yours onReceive(Context, Intent)you get a Context object that has a method getContentResolver().

+12
source
ContentResolver contentResolver =context.getContentResolver();
cursor = contentResolver.query(uri, projection, selection, selectionArgs, sortOrder);
0

All Articles