how to load or retrieve a webpage in both online and offline mode in android application? how to load or retrieve a webpage in both online and offline mode in android application? android android

how to load or retrieve a webpage in both online and offline mode in android application?


I don't know is this solution suitable for your.if you want to view a website in offline mod and online mod you can use a web crawler to fetch all data from website.Here is an example project for android web crawler.after that you can load a website from url or local memory based on your internet Availability.


Get the HTML code from loaded WebView

Save String as html file android

With above two link you can achieve your requirement,you can store html content into file and then store into internal storage then you can load in offline mode.


A WebView can load and render remote and local html pages plus it also support 'data' scheme URL.

Storage Options

Shared Preferences (not useful in your case)

Store private primitive data in key-value pairs.

Internal Storage ( Recommended for your case )

Store private data on the device memory.

External Storage ( You can use in you case but not recommended )

Store public data on the shared external storage.

SQLite Databases ( You can use in you case but not recommended )

Store structured data in a private database.

Network Connection ( You can use in you case but will not work in offline mode )

Store data on the web with your own network server.