How do I catch content provider initialize?

pleerock picture pleerock · Mar 26, 2012 · Viewed 8k times · Source

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 provider's onCreate method would be called

Answer

pleerock picture pleerock · Mar 26, 2012

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
    }
}