jamen
jamen

Reputation: 423

DbAdapter class versus ContentProvider whats the difference in android?

I'm trying to find out what is the difference between setting up the database through DbAdapter class or setting up everything in Content Provider ?

Is it true that the DbAdapter class is more of a temporary stopgap while the ContentProvider is a long term solution that allows more functionalities such as search capability and stuff ?

Can an instance of the Dbadapter class be built within the ContentProvider ? such that I actually can just call and manage everything from the DB straight from the Provider class ?

Upvotes: 1

Views: 1005

Answers (1)

Damian
Damian

Reputation: 8072

I would definitely recommend investing some time learning how to write a ContentProvider. They are a little daunting at first but once you've mastered the concept you'll get payback bigtime; especially if you're creating a moderately complex app.

When using a ContentProvider:

  • Content providers can be used from other processes and are required by some mechanisms on Android like the global search
  • Other apps will be able to access your data.
  • You can wrap and abstract a lot of the query logic in your content provider, and limit access.
  • You will be able to lean on the system to allow for things like managed queries.

Indeed the ContentProvider is a wrapper around your DBAdapter providing standard method such as query, update, delete etc.

Here is a good tutorial: http://thinkandroid.wordpress.com/2010/01/13/writing-your-own-contentprovider/

Upvotes: 1

Related Questions