I have trouble with this simple piece of code. I download an image from the web and save it locally with :
File mFile = new File(context.getFilesDir(), "a.png");
if(!mFile.exists()) { mFile.createNewFile(); }
FileOutputStream fos = new FileOutputStream(mFile);
fos.write(baf.toByteArray());
fos.flush();
fos.close();
I try to display this image on the ImageView and it's working. Now i try to display the save image on a WebView.
String data = "<body>" +"<img src=\"a.png\"/></body>";
webview.loadDataWithBaseURL(getActivity().getFilesDir().toString(),data , "text/html", "utf-8",null);
It's not working, the webview shows nothing. I try the webview with a png i put myself in /assets and it's working.
I think my syntax to point to the file in the String data is wrong but i'm not sure.
Any help appreciated.
Thanks.
Alex.
Ok, after testing lots of different things, i end up with this working code.