In my application, I have created a ContentProvider. I开发者_运维百科s there a way for me to instantiate this ContentProvider
when my apk
is started?
Right now, the ContentProvider only instantiates when someone does a query.
What exactly do you mean by 'instantiate' your Content Provider? Generally you should be using a Content Resolver to access Content Providers rather than instantiating them directly.
If you want to initiate a query against your Content Provider when your application is first started, you can extend the Application
class and override the onCreate
method, making a query to your Content Provider from there.
If you go that way, you'll also need to modify the <application>
node in your manifest to include an android:name
attribute that specifies your new Application class implementation.
精彩评论