开发者

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. The URI for such content providers always starts with content:// as in:

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

My question: is it possible to implement a content provider that is not on the Android device?

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?

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 UR开发者_Python百科I start with 'content://'?


I don't think it is possible to create a content provider that is not on the Android device. A Content Provider is part of the Android framework and its resolution (i.e. what does the name maps to) is part of the framework as well. Realize that a URI that Android uses for the name of a service is not the same as a URL over the public internet.

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.


This is indeed possible and I don't think you'll find a better example than RESTProvider .

This exposes a contentprovider interface to REST API services and can be used with any remote service that returns XML or JSON.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜