When is a ContentProvider really created?
-
28-09-2019 - |
Question
I have a ContentProvider which is declared in the Manifest, when is it really created ? When the application is launched but before launching the first activity ? When the first query/update/insert is done ? When ?
Solution
When the first query/update/insert is done. Check this
Update: android documentation is invalid in this regard. Valid behaviour is descirbed here https://stackoverflow.com/a/11858493/657487
ContentProvider created when app starts. So, it might be wise to make onCreate() lightweight
OTHER TIPS
From http://developer.android.com/reference/android/content/ContentProvider.html#onCreate():
Implement this to initialize your content provider on startup. This method is called for all registered content providers on the application main thread at application launch time. It must not perform lengthy operations, or application startup will be delayed.