装载机可以在没有内容提供商或组合使用是必须? [英] Can loaders be used without content provider or combination is must?

查看:185
本文介绍了装载机可以在没有内容提供商或组合使用是必须?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 可以没有内容提供商或组合使用装载机是必须的?


  2. 它是只使用时,它的目的是内容提供商的最佳实践
    其他应用程序或仅为本地的使用也内容使用
    建议供应商?


  3. 如果在SQLite的更新数据,将Loader发布更新的数据,如果不与内容提供商使用吗?


我试图寻找令人信服的答案上述问题,但无法找到它。请帮忙。


解决方案

  1. 装载机是加载您的活动/片断信息,而无需在UI线程上执行计算的方法。它可以与内容提供商可以使用,也可以使用装载机/ AsyncTaskLoader的子类来访问你自己选择的数据。你可以找到关于如何以及何时这里使用Loader 更多信息。

  2. 这是使用一个内容提供商时,内容提供商可访问数据的最佳实践。它们由系统维护,并且确保所提供的数据的一致性的好方法。你可以创建自己的内容提供商,从一个应用程序到另一个提供数据。更多信息可以在这里找到

  3. 您可以通过本指南在第7的这里

  1. Can loaders be used without content provider or combination is must?

  2. Is it best practice to use content provider only when it is intended to use by other applications or for only local use also content provider is recommended?

  3. If data updated in SQLite, Will loader deliver updated data, if not used with content provider?

I have tried to find convincing answers to above questions, but could not find it. Please help.

解决方案

  1. A Loader is a way to load information for your activity/fragment without performing the computation on the UI thread. It can be used with a Content provider or you can use a subclass of Loader/AsyncTaskLoader to access data of your own choosing. You can find more info on how and when to use a Loader here.
  2. It is best practice to use a content provider to access data when a content provider is available. They are maintained by the system and are a good way to ensure the consistency of the data provided. You can create your own content provider to provide data from one application to another. More information can be found here.
  3. You can create a loader for an sqlite database by follwing the info in this guide at section 7 here.

这篇关于装载机可以在没有内容提供商或组合使用是必须?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆