0

i have a ContentProvider on my app, i use it to share images from assets folder. I used the solution proposed here: http://www.nowherenearithaca.com/2012/03/too-easy-using-contentprovider-to-send.html

Now i need to share images stored on the cache folder of my app. Would be nice to do it using the ContentProvider, but i can't find info about how to do it.

It is possible? If not, wich is the correct way to do it?

Thanks

NullPointerException
  • 36,107
  • 79
  • 222
  • 382

1 Answers1

1

If "the cache folder" is getCacheDir(), use FileProvider.

If "the cache folder" is getExternalCacheDir(), try my StreamProvider.

If you really want to bake this into your own provider, you would need to override openFile() and use ParcelFileDescriptor.openFile() to create a ParcelFileDescriptor on your desired file. You would also need to extend your getMimeType() and query() methods to return the MIME type and filename/size, respectively. It is likely to be easier just to drop in one of the canned implementations.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491