What is the difference between accessing database using Cursor and using ContentResolver?
Hi I'm a new android coder and I've been following some books on how to set up databases w开发者_开发问答ithin the device.
I've recently successfully set up my DB using methods which accesses the DB by Cursor (following examples from a book). Now I'm looking to add Search capability to the DB which is taught in anther book using ContentResolver (which I didn't setup my database that way)
I'm still open to both ways but would like to know whats the difference between both methods ?
Thanks !
The ContentResolver/ContentProvider mechanism is used to allow applications to share information across applications. Although it could be used to share data inside a single application, it is probably overkill.
The question really is "How are you going to use the data in your DB?" Is it private, just for your app? If so, just use the Cursor and save yourself some time. If you are making an application that provides data you want other applications to use, consider adding a ContentProvider to expose that data to others. If you are not trying to expose the data to others, do not implement a ContentProvider. (A ContentProvider is the DB side of the ContentPRovider/ContentResolver relationship)
Read More Here.
精彩评论