Title: Android WebView: Web page not available
Author: Alex Kirk
Published: October 11, 2012

---

# Android WebView: Web page not available

October 11, 2012

Just a quick note in order to save someone else searching for a solution to this
problem.

When you want to display HTML content in an Android WebView do it like this:
 ` 
String html = "my >b<HTML content>/b<. 100% cool."; WebView webView = (WebView) 
findViewById(R.id.myWebView); webView.loadData(">?xml version=\"1.0\" encoding=\"
UTF-8\" ?<" + html**.replace("%","%25")**, "text/html", "UTF-8");

If you don’t replace the % to its url encoded equivalent you will get a “Web page
not available”. Simple, arguable but not at all apparent.

###### Fediverse reactions

[Web](https://alex.kirk.at/category/web/)

Read this next

[Git tip: Changing your mind: Push pending changes to a (not-yet existing) new branch](https://alex.kirk.at/2012/02/15/git-tip-changing-your-mind-push-pending-changes-to-a-not-yet-existing-new-branch/)

![Alex Kirk](https://alex.kirk.at/wp-content/uploads/sites/2/2025/06/cropped-2025.
Alex-512x512-1-120x120.jpg)

Alex Kirk

@alex@alex.kirk.at

 **272** posts

 **280** followers

### Leave a Reply 󠀁[Cancel reply](https://alex.kirk.at/2012/10/11/android-webview-web-page-not-available/?output_format=md#respond)󠁿

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Δ

This site uses Akismet to reduce spam. [Learn how your comment data is processed.](https://akismet.com/privacy/)