What would be the best way to force Android to store a webview to a media once the page is loaded?
A few more details:
Each page will be rich with images, scripts and styling.
Each page will be about 0.5 to 1 Megabyte.
They will be saved once the OnFinishedLoading Override is called.
It would be best to save it to the SD Card then use the local repo to open it back up.
Not sure if I should just use a sql database for the webviews, or take each view and do a write out to a file.
If I do the latter, what would be the easiest way so I don't have to write a full webcrawler to get each file linked?
In order to use caching on Android, you need to provide an HTML5 manifest file along with your HTML.
<!DOCTYPE html>
<html lang="en" manifest="manifest.file">
<head> ...
The caching mechanism will cache whatever entries you will list in the manifest file into an SQLite database. Keep in mind that the database is per app, not per webview. (I had a lot of problems with this).
This article explains all the steps you need to take to achieve this. http://web.archive.org/web/20140314001433/http://alex.tapmania.org/2010/11/html5-cache-android-webview.html
You can do a hello-world example for caching using this page: http://html5demos.com/offlineapp
You can save the cache on the SD card, as long as you add the WRITE_EXTERNAL_STORAGE permission to the application manifest.
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With