Android. Content provider or Database?

后端 未结 3 597
北海茫月
北海茫月 2020-12-08 07:16

I\'m a bit confused in the question, if it\'s better to use ContentProvider or Database. Or it makes no difference if I don\'t want to share any da

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 07:50

    Reasons to use content provider are here.

    In summary:

    1. Easily change the underlying data source (you can change your db from Sqlite to Mongo or to a JSON file without any app changes)
    2. Leverage functionality of some Android Classes (SyncAdapter, Loaders, CursorAdapter) - These classes require content provider and you cant use them if you dont have one
    3. Allow many apps to access, use and modify a single data securely. (which is really the main reason for using it)

提交回复
热议问题