简体   繁体   English

Android内容提供商*不是*在Android中?

[英]Android Content Provider *not* in Android?

So far, all content provider tutorials I found, teach how to implement a content provider locally, on the Android device. 到目前为止,我发现的所有内容提供程序教程都教如何在Android设备上本地实现内容提供程序。 The URI for such content providers always starts with content:// as in: 此类内容提供者的URI始终以content://开头,如下所示:

content://com.google.provider.NotePad/notes/23

My question: is it possible to implement a content provider that is not on the Android device? 我的问题:是否可以实现不在 Android设备上的内容提供程序?

That is, a content provider that follows all the conventions and convenience of Android content providers but is rather located on a remote website, using MySQL for example, instead of SQLite3? 就是说,一个内容提供商遵循Android内容提供商的所有约定和便利,但是位于远程网站上,例如使用MySQL代替SQLite3?

If so, how do I go about implementing such content provider? 如果是这样,我该如何实施此类内容提供商? Where do I find information that teaches how to do that? 我在哪里可以找到教该如何做的信息? Does such content provider's URI start with 'content://'? 此类内容提供者的URI是否以“ content://”开头?

I don't think it is possible to create a content provider that is not on the Android device. 我认为无法创建不在Android设备上的内容提供程序。 A Content Provider is part of the Android framework and its resolution (ie what does the name maps to) is part of the framework as well. Content Provider是Android框架的一部分,其解析度(即名称映射到的内容)也是该框架的一部分。 Realize that a URI that Android uses for the name of a service is not the same as a URL over the public internet. 请意识到,Android用于服务名称的URI与公共互联网上的URL不同。

If you want to connect to some server side data over the public internet, it is best to wrap it in some web service that will return JSON or XML to avoid database connection issues. 如果要通过公共Internet连接到某些服务器端数据,则最好将其包装在某些Web服务中,该服务将返回JSON或XML,以避免数据库连接问题。

This is indeed possible and I don't think you'll find a better example than RESTProvider . 这确实是有可能的,我认为您不会找到比RESTProvider更好的示例。

This exposes a contentprovider interface to REST API services and can be used with any remote service that returns XML or JSON. 这向REST API服务公开了contentprovider接口,并且可以与任何返回XML或JSON的远程服务一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM