2

I am building an application which loads HTML files stored on my android device. The files are typically quite large(6MB for example). If I load these HTML files it takes quite a long time to display them(20 to 25 seconds). Can anyone give me some advice about how to improve this loading time? code I tried so far:

final WebView webView = (WebView) findViewById(R.id.webView1); webView.loadUrl("file:///android_asset/content.html"); webView.getSettings().setCacheMode(<all cache modes>) 

I tried this on android 2.3 and 4.0, Android 4.0 performs actually worse then 2.3.

Any hints about how to improve performance?

4
  • Are you loading images? Improve your HTML files to load faster. Commented Jun 25, 2012 at 13:00
  • can you post content.html? If it is calling links from the net could definitely slow things down. Also you might want to take a look at utilizing loadData or loadDataWithBaseURL. developer.android.com/reference/android/webkit/… Commented Jun 25, 2012 at 13:05
  • @slybloty Yes, there are also images in the HTML. Any hints how to speed up/improve the loading? changeing the HTMl should be a last resort measure due to copyrighted content, but if there is no other way then I will try that... any hints how to achieve this? Commented Jun 25, 2012 at 13:07
  • @MikeIsrael sorry, but due to copyright reasons I am not allowed to publish these content files, however all content is available on my device, so no network access is needed... Commented Jun 25, 2012 at 13:09

2 Answers 2

1

Really a broad discussion. You might need to be more specific. So here it goes....

  1. In general speed up your pages -- http://developer.yahoo.com/performance/rules.html

  2. If loading more than one file at a time load asynchronously --http://developer.android.com/reference/android/os/AsyncTask.html

  3. Minimize pictures if at all possible or load them last

  4. public void loadDataWithBaseURL (String baseUrl, String data, String mimeType, String encoding, String historyUrl) and cache it for later use to load faster 2nd or third time

Sign up to request clarification or add additional context in comments.

Comments

0

OK so try the loadData method, it might be a bit faster.

String summary; ...//convert your file to a string and store in summary variable webview.loadData(summary, "text/html", null); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.