Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I save a complete webpage displayed in Android's WebView?

I am developing an Android application in which I have a WebView. I want to save the entire webpage loaded in this webview (Html + all resources + images + icons etc) into a folder and zip it and upload it to a server.

If you use WebView's saveWebArchive, then it is saved in archive format. How do I get the Html and images back from this archive? Is there any documentation for the format of this archive?

If I use addJavaScriptInterface to get the html as described here, I still have to copy the images and other resources from the webview cache dir (/data/data/your app package/cache/webviewCache/). However I did not find webview cache dir (/data/data/your app package/cache/webviewCache/) in Icecream Sandwich.

Is there a way to save the entire webpage displayed in webview along with resources in Android?

Thanks

like image 635
user1172562 Avatar asked Jun 13 '12 18:06

user1172562


2 Answers

If anyone is still interested, there is an open source project here that can read WebView's archive format (saved with saveWebArchive) and display it back in a WebView.

https://github.com/gregko/WebArchiveReader

I couldn't find details of the actual format yet.

like image 63
Indivara Avatar answered Oct 24 '22 04:10

Indivara


You can use HTML 5 to store pages in the cache and load from the cache itself.

Caching is easy using HTML5, all you have to do is to make and refer a manifest file that holds information on what all elements need to be cached. http://www.html5rocks.com/en/tutorials/appcache/beginner/

And here is a good way to implement the cache feature in your webview. http://alex.tapmania.org/2010/11/html5-cache-android-webview.html

Aman Gautam

like image 1
Aman Gautam Avatar answered Oct 24 '22 06:10

Aman Gautam