0

I really love the concept of 'Loaders', 'ContentProviders' and especially 'ContentObservers'. I use this standard pattern where data is loaded from a local db and when it's updated from my server it's refreshed with getContentResolver().notifyChange() or something like this.

But when I use ContentProvider I have to expose my data to other apps. Why is that? I don't have any sensitive data, but it doesn't seem very elegant to me. So did I miss something here, or using ContentProvider (and thus exposing my data) is the only way to implement it easily.

What I really miss from other implementation options is to notify Loaders that new data appeared in local db.

Michał Klimczak
  • 12,674
  • 8
  • 66
  • 99
  • 1
    You missed this http://stackoverflow.com/questions/3814610/android-private-content-provider – user Nov 06 '12 at 20:48
  • 2
    or protect it with your own [`android:permission`](http://developer.android.com/guide/topics/manifest/provider-element.html) if you want to expose it to your apps only – zapl Nov 06 '12 at 21:00

1 Answers1

0

Just to be perfectly clear here: you do not have to expose your data to other apps when you use a content provider. Instead, you can use the android:exported="false" attribute in the element in your manifest.

Using permissions to restrict access to a provider (but not prevent it) is described in great detail in Creating a Content Provider in the Android API guide.

Joe Malin
  • 8,621
  • 1
  • 23
  • 18