Android系统。内容提供商或数据库? [英] Android. Content provider or Database?

查看:101
本文介绍了Android系统。内容提供商或数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点困惑的问题,如果它是更好地使用的ContentProvider 数据库。或者,它是没有,如果我不希望与其他应用程序共享的任何数据差异。

I'm a bit confused in the question, if it's better to use ContentProvider or Database. Or it makes no difference if I don't want to share any data with other applications.

如果我的理解是正确的,根据的SQLite DB的内容提供商,它也有可能是其中的内容仅accessable我的应用程序。

If I've understood it right, content providers based on SQLite DBs and it's also possible that content of them is only accessable for my application.

您可以解释一下?

非常感谢你,

穆尔

推荐答案

恕我直言,内容提供商都在寻找有价值的问题的解决方案。

IMHO, content providers are solutions in search of worthwhile problems.

当然有值得的问题,特别是对跨进程数据发布。例如,你需要使用一个内容提供者提供搜索建议以快速搜索框。

There certainly are worthwhile problems, particularly for cross-process data publishing. For example, you need to use a content provider to supply search suggestions to a Quick Search Box.

然而,对于一个应用程序内部使用,我仍持怀疑态度。带来的好处(例如,单线程罗伯特提到),恕我直言,通过成本抵销(例如,弹性减弱相比的SQLite和 rawQuery())。

However, for internal use within an application, I am still skeptical. The benefits (e.g., the single threading that Robert mentions) IMHO are outweighed by the costs (e.g., reduced flexibility compared to SQLite and rawQuery()).

这些日子之一,我想到的是,卡通灯泡将照耀在我的头上,我终于弄清核Android团队对于内容提供商的思维。这也确实发生过针对Android的其他领域。目前,虽然,思想气球在我的头上充满了问号,而不是电灯泡。

One of these days, I expect that the cartoon light bulb will shine over my head, as I finally figure out what the core Android team was thinking with respect to content providers. That certainly has happened for other areas of Android. At the moment though, the thought balloon over my head is filled with question marks, not light bulbs.

如果你实现一个内容提供商,请记住,他们是被其他应用程序访问的默认。您需要包括安卓出口=假<供应商> 元素,使之私您应用程序。

If you do implement a content provider, bear in mind that they are accessible by other applications by default. You need to include android:exported="false" in the <provider> element to make them private to your app.

这篇关于Android系统。内容提供商或数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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