Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does ContentProvider.onCreate() get called before Application.onCreate()?

Tags:

android

I registered a ContentProvider in AndroidManifest.xml, and the ContentProvider.onCreate() was called even before the Application.onCreate(). I don't understand this behavior, in my opinion, It's more natural that Application.onCreate() be called before any of the components in the application. Could someone tell me the timing of Application.onCreate() and other components' onCreate() gets called?

like image 311
Dagang Avatar asked Aug 03 '12 03:08

Dagang


People also ask

When ContentProvider onCreate called?

Called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created.

What is it called when an application is onCreate?

onCreate() - called before the first components of the application starts. onLowMemory() - called when the Android system requests that the application cleans up memory. onTrimMemory() - called when the Android system requests that the application cleans up memory.

How many Contentprovider Can an app have?

You can implement as many as you want, as you can see from the documentation here. To register a content provider, you need to add its corresponding <provider> tag in the Android Manifest. In most cases, however, you won't need multiple content providers. One is usually enough, as it can handle multiple tables.


1 Answers

According a Google's issue it's how this should work (although documentation is wrong).

There's another question that have a workarround that can help you.

like image 153
lujop Avatar answered Sep 18 '22 15:09

lujop