tags:

views:

197

answers:

3

Hello friends, i have done SQLite database programming for Android, but i dont know anything about Content-Provider except this: "As i have referred Android Developer page , Android SDK explained about "Content-provider" as it is used to store and retrieve data."

But then,

  1. What is the exact difference between "Content-Provider" and "SQLite Database"?
  2. Which is best to store data, when ?

Any example or helps !!

+6  A: 

What is the exact difference between "Content-Provider" and "SQLite Database"?

ContentProvider is a facade -- an API you can implement that exposes databases to other processes. It can be implemented in a way where the data is stored in a SQLite database, but it does not have to be.

Which is best to store data, when ?

That is impossible to answer in the abstract. Generally speaking, unless something is requiring you to use a ContentProvider, just use a database.

CommonsWare
I prefer using a ContentProvider as it's a very nice abstraction over SQL. You can also play nice with CursorAdapter and automatic requeries.
alexanderblom
+1  A: 

Content Providers are used when you want to share your data across applications.

If you have a database attached with an application and you want another application to use some data, you can implement a content provider that exposes the data

Mina Samy
+1  A: 

I found one major difference, as follows:

Storing your data in a database is one good way to persist your data, but there's a caveat in Android-databases created in Android are visible only to the application that created them. That is to say, a SQLite database created on Android by one application is usable only by that application, not by other applications.

So, if you need to share data between applications, you need to use the content provider model as recommended in Android. This article presents the basics of content providers and how you can implement one.

I found this article at this link: http://www.devx.com/wireless/Article/41133

Really nice information provided.

PM - Paresh Mayani