As we know content provider loads on application run. But I want to make some operations before content provider will launch. How do I catch this operation? Before content p
My solution requires use of the call(Uri, String, String, Bundle)
API (so, it's not fully backward-compatible). But I have the stuff that I want the ContentProvider
to prepare before it is used in my override of that call
method. Then I do getContentResolver().call(BASE_URI, METHOD, null, Bundle.EMPTY)
in my Application.onCreate()
. Essentially, it defers that stuff until after my Application
is being created, which is what we expected the ContentProvider
's onCreate
to be doing naturally.
I think Ive found solution. Ive created my custom application class and overridden attachBaseContext method
<application android:name=".ApplicationController" ...>
public class ApplicationController extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// some of your own operations before content provider will launch
}
}