如何管理多表数据库?
我刚刚复习完记事本教程并了解他们如何处理数据库。如果您想将其扩展到多表数据库,您是否只需添加一个新的提供程序类来执行该表可能需要的任何操作?
其次,如果您不介意回答第二个稍微相关的问题,什么是 URI 以及如何在 android 中使用它们?我四处搜寻,只得到了“通用资源标识符”。
感谢 ~伊顿
I just got done reviewing the Notepad tutorial and looking at how they do their database. If you wanted to expand it to a multi-table database, would you just add a new provider class that did anything possibly needed for that table?
Second If you don't mind answering a second slightly related question, What is a URI and how do I use them with android? I searched around and only came back with "Universal Resource Identifier".
Thank
~Aedon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
提供者的想法是它处理一种公共资源。因此,您有一个联系人提供程序或一个注释提供程序。提供程序不以任何方式与数据库绑定。注释提供程序可能会访问提供程序接口后面的数十个表。
您可以将提供程序接口视为您的资源的公共 API。它可作为共享公共资源的机制供手机上的所有应用程序使用。实现该 API 的方法是提供者本身的实现细节。提供程序可能根本不使用数据库(也许它仅使用 Web 服务),或者可能使用多表/多数据库设计。
URI 是通用资源指示符。 Cliff 对此的注释是这样的: uri 有一个方案和一个定位器。在 android 中,方案(即 : 之前的 uri 部分)用于确定 uri 的用途。像 sms://5555555551 这样的 URI 被注册为请求发送文本 555-555-5551。 555-555-5551 被称为“数据”。
此处还有更多内容需要阅读和理解。可以说,在 Android 中,URI 经常用于将活动松散地耦合在一起。例如,在我之前的示例中,我只关心发送短信,而不关心它是如何发送的。这使得许多应用程序注册后能够发送短信,这些应用程序可能比 Android 内置到平台中的应用程序更好。
The idea of a Provider is that it deals with a type of public resource. So you have a Contact provider or a Note provider. The provider isn't tied to the database in any way. A Note provider might be accessing dozens of tables behind the provider interface.
You can think of the provider interface as being being a public API to your resources. Its available to all applications on the phone as a mechanism for sharing a common resource. The method of implementing that API is an implementation detail for the provider itself. The provider might not use a database at all (perhaps it uses a web service only) or it might use a multitable/multidatabase design.
A URI is a Universal Resource Indicator. The Cliff's notes of it are this: The uri has a scheme and a locator. In android, the scheme, the portion of the uri before the :, is used to determine what you intended for the uri to do. A URI like sms://5555555551 is registered to be requesting a text to be sent 555-555-5551. The 555-555-5551 is referred to as the 'data'.
There is much more to read and understand here. Suffice to say, in Android, URI's are frequently used to loosely couple activities together. For instance, in my previous example, I care only that an sms is sent, not how it is sent. This allows many apps to register to be able to send sms messages, apps better, perhaps, then the ones that Android has built into the platform.