onCreate of Content Provider
Asked Answered
B

3

10

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?

Boating answered 21/3, 2012 at 4:44 Comment(0)
I
10

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

Innovate answered 21/3, 2012 at 4:57 Comment(4)
also, if u don't mind.. could you pls explain what is the control flow.. i mean how does it happen? I am not getting which method is being called after each?Boating
You are asking me a bit more conceptual question... of which i am not sure...=].. but this is what i understood from the documentation.. while launching the app.. the manifest is checked for any contentproviders.. and if any..their oncreate is called.. so that they are available for your application as soon as it is created..Innovate
yes.. i understand that. I wanted to know when does actually the DB gets created what are the lifecycle methods and what is the sequesnce of method execution in this project?Boating
Sneha, if you have a follow up question(s), you can ask an entirely new question (or questions.)Rufusrug
C
0

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?

Chancroid answered 26/3, 2012 at 15:9 Comment(0)
S
0

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.

Skaw answered 10/4, 2020 at 7:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.