I found that onCreate of ContentProvider gets called first, even before the onCreate of my Activity. eg: Vogella Android SqlLite.
But I wanted to know how does it happen and why?
Is it because we register it as a provider in the Manifest?
I found that onCreate of ContentProvider gets called first, even before the onCreate of my Activity. eg: Vogella Android SqlLite.
But I wanted to know how does it happen and why?
Is it because we register it as a provider in the Manifest?
onCreate is 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.. yes ,it is because you register them in manifest...
Ive faced with the same problem as you. If you want to know when your content provider initializes see my answer here How do I catch content provider initialize?
ContentProvider.onCreate()
(which is defined in manifest) is created before Application.onCreate()
[Multiprocess Application](the same as before other Android components - Activity, Service, Broadcast receiver). It is created and initialised in the main thread
You can find that some libraries use this approach to not force a developer to init the library into Application.onCreate() method and passing the context.
© 2022 - 2024 — McMap. All rights reserved.