开发者

How to instantiate my Content Provider up front?

开发者 https://www.devze.com 2022-12-14 15:02 出处:网络
In my application, I have created a ContentProvider.I开发者_运维百科s there a way for me to instantiate this ContentProvider when my apk is started?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号