Working on Power Schedule, I wanted to make a short help file, with some formatting. It seems there were several ways of doing this, but I chose to include an embedded HTML file into my application. It seemed easier to just edit an HTML file in an editor.
So let’s get started…

  • first, embed an html file in the app resources. For this, create the “raw” subfolder in “res” folder and add your HTML formatted file:
    Add raw HTML file
  • use a WebView view in your layout file:
    	<WebView xmlns:android=""
    		android:id="@+id/webviewHelp android:layout_width="fill_parent"
  • use this code in your activity onCreate() method:
    		WebView webview = (WebView) findViewById(;
    		webview.loadData(readTextFromResource(, "text/html", "utf-8");

    where readTextFromResource is something like this:

    	private String readTextFromResource(int resourceID)
    		InputStream raw = getResources().openRawResource(resourceID);
    		ByteArrayOutputStream stream = new ByteArrayOutputStream();
    		int i;
    			i =;
    			while (i != -1)
    				i =;
    		catch (IOException e)
    		return stream.toString();

It will look something like this:
HTML file on Android

I hope it helps :)