TUTORIAL: Add HTML to Android App

When you’re creating an Android App there is a high chance you’ll have to add html to android. For example a Help content or FAQ page. You can also use html in android, but you’ll have to add an assets folder in Android Studio (your project) before you can start using html in your Android Application.

In this tutorial I’ll show you how you add html to android app.

 


tutorial: Add HTML to Android App

Before we start; open your Android project in Android Studio. Or download Android Studio here.

  1. Right click on “app” in the upper left corner.
  2. Click New 
  3. Click Folder
  4. Click Assets Folder
assets folder android
assets folder android

Lets not change the Target Source Set unless you know what you’re doing.

  • Click Finish
html android studio
html android studio
  1. Right click Assets
  2. Click New
  3. Click File
add html to android app
add html to android app
  • Name your html file and add .html
add html android studio
add html android studio

Add your html content or copy your html file from your PC to Android Studio.

You can use the index.html file by adding the following code snippet to your MainActivity.java

WebView view = new WebView(this);
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl("file:///android_asset/index.html");
setContentView(view);

For more Webview classes click here.