Serving images through a content provider in Android

So, in my application, the user will find images, like a concept art feature in video games. I want these images to be enlarged, separated and no matter how in the gallery application. What is the best way to display them? I think the correct way to do this is to send Intent.ACTION_VIEW with the image type / png, so any program can get it ....

But in this case, the images should be available for any application, they cannot be a resource, right? (Because then they will not be available for other applications.) Therefore, they must be available through the content provider ...

I donโ€™t think I can just insert them into the default media content provider ... because will they not be available for viewing through the gallery application? I want the user to "unlock" them over time. So I need to create my own content provider and post images through this, right? What is the best way to make a content provider that can serve images (and video, audio, possibly contacts or other types of objects)?

+6
source share
4 answers

I suggest you create your own ContentProvider and handle all the business logic. Images will not be available for the gallery application unless they are inserted into the Media Content Provider. You can do this by manually pasting in your content provider, or let MediaScanner automatically find files if you store them in a public directory on your device and insert them over time.

+1
source

Why don't you just copy the image to external storage?

After copying it, you can update the media content provider. How to do this in this matter .

0
source

You can copy your images to the public media directory, then initialize the MediaScanner scanning process, and then these images will be accessible from the Gallery application

0
source

Plz follow this link .... http://developer.android.com/guide/topics/providers/content-providers.html#creating .. this can help you get started ... you need to save your images in sqlite db .. and share db with other applications as Content Provider.

-1
source

Source: https://habr.com/ru/post/891406/


All Articles