2

I have read that content provider is for sharing the data with other application.

In my app I haven't used content provider as I don't need to share my data with other application. So I used sqlite database alone. For underlying dataset change I used loadermanager with forceload content observer for instant loading.

Is this a bad practice? Does all application use content provider? Also I am going to develop new application and in that I am going to use syncadapter, should I go with same approach as I did before or do I need to use content provider?(remember: in this case also I don't want to share my data with other app)

Gaurav Jindal
  • 227
  • 4
  • 17
Medlin Moni
  • 91
  • 2
  • 13

2 Answers2

0

Content Provider are not always necessary if you don't want to share data with other app, but apart from that content providers are useful as, now you don't need to work out with your own loader. Beyond this also it has many good points, you can read views from various people over this from here.

But in my opinion if you are making an app with is likely to evolve over time then you should use Content Provider as it will help you to make things done at that moment.

Community
  • 1
  • 1
Gaurav Jindal
  • 227
  • 4
  • 17
0

The documentation says:

You don't need to develop your own provider if you don't intend to share your data with other applications. However, you do need your own provider to provide custom search suggestions in your own application.

That the default cursor loader implementation requires a content provider is a design bug. However, you can easily write your own cursor loader that does not need a content provider.

That the sync adapter requires a content provider is a design bug. However, even the Android documentation itself shows how to write a stub content provider that does not actually do anything.

Community
  • 1
  • 1
CL.
  • 173,858
  • 17
  • 217
  • 259