I am making an app that has to display the content of a website. I created my website I want to use and it will be responsive so that it works with different devices. The question is how do I download the html code of my website periodically (once a day) and display the downloaded html files in my webview. the [page will contain only a simple table that I will regularly update online. I would like if you could tell me the steps to achieve this? Thank you in advance!
Asked
Active
Viewed 741 times
-1
-
You need to write and host webAPIs for this. You can read about following topics in android domain to find answers: -Consuming Rest/Ksoap APIs in android -JSON/XML Parsing – Parth Kapoor Jan 27 '15 at 12:16
-
@Eu.Dr. I want to download the webpage as a whole so I dont think I need a webAPI , it all has to be on the android side. I saw some solutions but I wanted to see more precisely how to to it.. – drilonrecica Jan 27 '15 at 12:27
1 Answers
0
If it's not necessary to download the html code & display the updated, you can display the whole website by providing the url to webview, you only need to change the view of website for mobile devices & it will be reflected in the webview.
And if this is not the thing you want then you need to perform webservice call which in return provide you JSON String, parse it into local string & replace the html code.
public class Main extends Activity {
private WebView mWebview ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mWebview = new WebView(this);
mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript
final Activity activity = this;
mWebview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
}
});
mWebview .loadUrl("http://www.google.com");
setContentView(mWebview );
}
}

Zeeshan Saiyed
- 466
- 4
- 13
-
thank you very much , I asked this question because I did not know how to otherwise cache a website so when Im not connected to the internet I could see the last saved state of the website in the webview. Do you have any suggestions how to do this? – drilonrecica Jan 27 '15 at 14:46
-
please refer this link http://stackoverflow.com/questions/14670638/webview-load-website-when-online-load-local-file-when-offline – Zeeshan Saiyed Jan 28 '15 at 05:57