jeudi 3 septembre 2015

when should I use a content provider in android

I am trying to understand in what situation my app might use a Content Provider to manage its data. I am not interested in providing data to other apps, just as a general abstraction/interface above sqlite.

So, for easy framing, my question is this: Does an app like Youtube need a content provider? I am asking the question in the context of a local cache. More broadly: does any app that behaves like a search engine need to use contentProvider/sqlite?

For instance I understand that a weather app might use a content provider since weather data does not change all that often and a 7-day forecast will not change from hour to hour. So in that sense I might use a contentProvider so as not to query the server each time a user checks but rather I might do the check, say, every three hours.

But for an app like Youtube, where the user is allowed to search for data, what would I put in a contentProvider and what advantage does such caching provide? Do I put the search result, playlist, favorites? Also might it make sense for Quora to cache the Trending stuff in a contentProvider since that might not change all that often?

Instead of a ContentProvider, should such data be stored in an in-memory cache? And yes do take into account that Youtube serves videos. I am really hoping to get some expert answers here. Thanks.

Aucun commentaire:

Enregistrer un commentaire