سؤال

I have a task that sounds simple, but I have not yet figured out how to do it. I have a URL in my Android App. Now I want to download it, save it on my device, and then load it into a webview (let's say it is an image). I have to load my file from the device itself, so I cannot just load my image into my webview.

And the image has to be stored permanently. So that I can reopen it after closing the app even without internet connection.

I know how to work with Assets, but I cannot store files there that I am downloading during runtime, if I got this right.

هل كانت مفيدة؟

المحلول

If you are saving file in an html format on sd card you can load it in web view as shown below

webView.loadUrl("file://"+Environment.getExternalStorageDirectory()+"/filename.html");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top