ElGreco4535
ElGreco4535

Reputation: 23

Best way to get images out of SQLite DB and show them in WebView (Android)

I have a SQLite database with several (small) images that I want to be displayed within a WebView. I am trying to use a contentprovider that caches the images to the filesystem, but I think that this is not a good approach.

Is there a possibility to get the imagedate directly to the webview without caching?

Upvotes: 2

Views: 963

Answers (1)

Daniel  Magnusson
Daniel Magnusson

Reputation: 9674

If the images are very small, just have them base64 encoded within the html page you have saved in the SQLite databasse.

<img src="data:image/png;base64,<BASE64 IMG STRING>" />

The browser should be able to decode them on the fly, and then you do not have to take the "save to filesystem-> read from filesystem" round-trip.

Upvotes: 2

Related Questions