Android WebView: Use Local HTML Folder If The User Is Offline, And Use The Remote URL If The User Is Online 🎯

Manager with smartphone

The WebViewGold Android App Template is very flexible when it comes to offline/online status handling. In general, there are three modes:

 

Option 1: Use a URL for accessing your web application (= store files online)

Option 2: Use a local HTML folder for accessing your web application (= store files within the app)

Option 3: Use an HTML folder if the user is offline, and use a remote URL if the user is online (= store files online + store backup/fallback files within the app)

 

Get the WebViewGold App Template for Android Studio here. In order to activate the third mode, just copy your HTML/CSS/JavaScript files to the Android Studio project, set USE_LOCAL_HTML_FOLDER to false and set FALLBACK_USE_LOCAL_HTML_FOLDER_IF_OFFLINE to true.