Sohan,

Using a ContentProvider has some benefits over using a "raw" SQLLite database.

- The lifetime of a ContentProvider is managed by Android, this helps if data storage is used by several activities.

- A ContentProvider implementation can notify open cursors about data changes, this means you get "live" ListViews (for example) with no extra effort.

- You can export a ContentProvider from one application and use it in another. You can restrict what applications are allowed to use a ContentProvider by using manifest-based permissions (separate for reading and writing) .

-- Kostya

09.08.2010 14:46, Sarwar Erfan пишет:

On Aug 9, 3:36 pm, Sohan badaya<sohan.bad...@gmail.com>  wrote:
Hi All,

I have a doubt about content provider. Why we use content provider?
can't we use database of a application?
You do not have access to other databases (and there is not valid
reason to allow you to do so)


If we talk about other application also. can't we use database of that
application directly wihout
content provider?

You don't want other applications to view/edit your entire database.
Other application developers don't want to know about the relations
between several tables.
And, if they don't know the logic and messes up with some keys, your
data will become unusable.
Not all databases are simple, sometimes, information about a single
entity can be distributed among several tables.
And, for inserting, there may be some pre-processing before inserting,
the ContentProvider will do that for you.


Thanks,
Sohan


--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to