ContentProvider destruction/lifecycle
android, android-contentprovider
Solution
I'm especially interested in if, when and under what circumstances a provider is destroyed
It is created when your process is started (even before your `Application` object is created), and it lives until the process is terminated.
how long does its process live?
That varies based upon what is going on with the app, the user, and the device.
Would that process continue to run indefinitely?
No.
When the system is running low on resources, Android destroys components like Services.
No, it does not. When the system is running low on RAM, Android terminates processes.
Are ContentProviders not also candidates for being destroyed when resources are tight?
A process containing a `ContentProvider` can be terminated, whether due to low memory conditions, old age, user action, etc.
Problem
I'm curious if someone can explain the lifecycle of a ContentProvider. I'm especially interested in if, when and under what circumstances a provider is destroyed. That doesn't appear to be covered by the documentation. The ContentProvider section of this article talks about documentation being hard to come by but it includes a link to a Google Groups discussion where an engineer at Google left a quick response, stating that "content providers are never destroyed. They exist for the entire lifetime of their process." Okay, so maybe a ContentProvider lives as long as its process but how long does its process live? Suppose I have an application that provides a ContentProvider and a query from another application is the only reason my ContentProvider's process was created (i.e., there's not also an Activity or Service running.) Would that process really continue to run indefinitely? When Android is running low on resources, it destroys components like Services. Are ContentProviders not also candidates for being destroyed when resources are tight?