I have already created the app, but it needs to be connected to the internet to work. In essence it just displays the website through an app. I would like to have the website installed on the app so that it can load without requiring an internet connection.
I have downloaded my webpage while, and added it to the Android SDK. Its saved it under the Java section. Now the code I used to load the webpage while online was the following:
mWebView = (WebView) findViewById(R.id.activity_main_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("http://kuglerdesign.com/");
mWebView.setWebViewClient(new MyAppWebViewClient());
I have searched on stackoverflow for a similar question, and have found the following lines of code:
URL url = this.getClass().getResource("/com/path/to/file.txt")
File file = new File(url.toURI());
and these from a different answer:
File currFile = new File(getClass().getClassLoader().getResource("the_file.txt").getFile());
My question is how to implement these to a file thats in the Android SDK. Do I just replace all the mWebView and WebSettings or do I still need them as its a HTML file?
Or would I be better off just to set the mWebView Url to a local file? So replacing the following line of code:
mWebView.loadUrl("http://kuglerdesign.com/");
with this line :
mWebView.loadUrl("file:///kuglerdesign.html");
Any help would be greatly appreciated.
(sorry for being such a novice at Java :( ...)