20

I am working on an application where I load few websites in webview now I want to save webpages so after sometime even if there is not internet user will able to see those pages. But I am confused on how to save whole webpage in cache or any other medium. The main thing is we need to show pages back even if there is not internet. Has anyone implemented this before. Please provide some demo code as this is my first attempt on cache..

Thank You

Sandip Jadhav
  • 7,377
  • 8
  • 44
  • 76

1 Answers1

7

The easiest way is save webpages in cache directory or any other(Internal or external storage)

You can get the data of web page using HttpClient.execute() or HttpClient.get() now store that data in .html file also you have to download images or other contents which are bind to that page, Now in your application you have to check for connection if connection not available then load the page which one you saved in storage with file://<location of your webpage..>

EDIT:

I think using HTML5 you can display off-line webpages. (I never tried this, but I referred some blogs on it). Look at this nice post about HTML5 Creating mobile Web applications with HTML 5, Part 3: Make mobile Web applications work offline with HTML 5 Also this

hope this will help you.

user370305
  • 108,599
  • 23
  • 164
  • 151
  • @user370305---Thanks for quick reply.. Main thing is I want to implement this in android application using a webview Then link you are provided are best for native application but I am not doing native app.. Thanks for help.. – Sandip Jadhav Dec 07 '11 at 06:28
  • yes its good way but how to store images that used in HTML page and load when device have no internet in android – Parag Chauhan Oct 26 '13 at 14:10