We usually need HTML files for displaying your content in WebView. If you want to add any website page or want to create a local webpage for your app then it could be done using HTML files. Here we will show how to create local HTML file in Android Studio.
How to add local HTML file in android Studio
Step 1: For adding Local HTML page into your android studio project you must have Assets folder in it. Refer our Article :How to add Assets folder in Android Studio
Step 2: Once you have your assets folder inside the project then right click on assets folder then NEW>FILE
Step 4: Now you can see sample.html has created in the assets folder. Open it and edit as per your own requirements.
Step 5: Another option for adding HTML file: You can create a HTML page anywhere in your PC and then Copy it and paste it into assets folder.
Important Note: When you want to load your HTML page in web view then use below code:
WebView web = new WebView(); web.loadUrl("file:///android_asset/sample.html"); make sure you cast the web view before using loadUrl() function : web =(WebView)findViewById(R.id.webview);