简体   繁体   中英

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 URI 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 (ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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