{"id":695,"date":"2016-05-13T02:17:18","date_gmt":"2016-05-13T02:17:18","guid":{"rendered":"http:\/\/abhiandroid.com\/androidstudio\/?p=695"},"modified":"2018-06-05T07:21:32","modified_gmt":"2018-06-05T07:21:32","slug":"add-local-html-file-android-studio","status":"publish","type":"post","link":"https:\/\/abhiandroid.com\/androidstudio\/add-local-html-file-android-studio.html","title":{"rendered":"How To Add\/Create Local HTML File In Android Studio"},"content":{"rendered":"<p>We usually need HTML files for displaying your content in <a href=\"\/ui\/webview\" target=\"_blank\" rel=\"noopener noreferrer\">WebView<\/a>. 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.<\/p>\n<hr \/>\n<h4><strong>\u00a0How to add local HTML file \u00a0in android Studio<\/strong><\/h4>\n<p><strong>Step 1<\/strong>: For adding Local HTML page into your android studio project you must have Assets folder in it. Refer our Article :<strong><a href=\"\/androidstudio\/create-assets-folder-android-studio-html-files.html\" target=\"_blank\" rel=\"noopener noreferrer\">How to add Assets folder in Android Studio<\/a><\/strong><\/p>\n<p><strong>Step 2<\/strong>: Once you have your assets folder \u00a0inside the project then right click on assets folder then <strong>NEW&gt;FILE<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-730\" src=\"\/androidstudio\/wp-content\/uploads\/2016\/05\/assets-new-file-in-Android-Studio.jpg\" alt=\"assets new file in Android Studio\" width=\"605\" height=\"183\" srcset=\"https:\/\/abhiandroid.com\/androidstudio\/wp-content\/uploads\/2016\/05\/assets-new-file-in-Android-Studio.jpg 605w, https:\/\/abhiandroid.com\/androidstudio\/wp-content\/uploads\/2016\/05\/assets-new-file-in-Android-Studio-300x91.jpg 300w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/p>\n<p><strong>Step 3<\/strong>: Android Studio will show you a dialog box, it will ask you to give file name. Write any name as per your requirement.(for example: sample.html) and hit OK.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-731\" src=\"\/androidstudio\/wp-content\/uploads\/2016\/05\/file-name-html-in-Android-Studio.jpg\" alt=\"file name html in Android Studio\" width=\"428\" height=\"149\" srcset=\"https:\/\/abhiandroid.com\/androidstudio\/wp-content\/uploads\/2016\/05\/file-name-html-in-Android-Studio.jpg 428w, https:\/\/abhiandroid.com\/androidstudio\/wp-content\/uploads\/2016\/05\/file-name-html-in-Android-Studio-300x104.jpg 300w\" sizes=\"auto, (max-width: 428px) 100vw, 428px\" \/><\/p>\n<p><strong>Step 4<\/strong>: Now you can see sample.html has created in the assets folder. Open it and edit as per your own requirements.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-732\" src=\"\/androidstudio\/wp-content\/uploads\/2016\/05\/html-in-assets-folder-Android-Studio.jpg\" alt=\"html in assets folder Android Studio\" width=\"510\" height=\"146\" srcset=\"https:\/\/abhiandroid.com\/androidstudio\/wp-content\/uploads\/2016\/05\/html-in-assets-folder-Android-Studio.jpg 510w, https:\/\/abhiandroid.com\/androidstudio\/wp-content\/uploads\/2016\/05\/html-in-assets-folder-Android-Studio-300x86.jpg 300w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/p>\n<p><strong>Step 5<\/strong>: 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.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-733\" src=\"\/androidstudio\/wp-content\/uploads\/2016\/05\/Create-HTML-page-in-Android-Studio.jpg\" alt=\"Create HTML page in Android Studio\" width=\"475\" height=\"115\" srcset=\"https:\/\/abhiandroid.com\/androidstudio\/wp-content\/uploads\/2016\/05\/Create-HTML-page-in-Android-Studio.jpg 475w, https:\/\/abhiandroid.com\/androidstudio\/wp-content\/uploads\/2016\/05\/Create-HTML-page-in-Android-Studio-300x73.jpg 300w\" sizes=\"auto, (max-width: 475px) 100vw, 475px\" \/><\/p>\n<p><span style=\"color: #ff0000;\"><strong>Important Note:<\/strong><\/span>\u00a0When you want to load your HTML page in web view then use below code:<\/p>\n<pre>WebView web = new WebView();\r\nweb.loadUrl(\"file:\/\/\/android_asset\/sample.html\");\r\nmake sure you cast the web view before using loadUrl() function :\r\nweb =(WebView)findViewById(R.id.webview);<\/pre>\n<p><strong>Also Read: <\/strong><br \/>\n1. <a href=\"\/ui\/webview\">WebView Tutorial<\/a><br \/>\n2. <a href=\"\/ui\/html\">HTML in Android Tutorial With Example<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. \u00a0How to add local HTML &hellip; <a href=\"https:\/\/abhiandroid.com\/androidstudio\/add-local-html-file-android-studio.html\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How To Add\/Create Local HTML File In Android Studio<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63,1,62],"tags":[],"class_list":["post-695","post","type-post","status-publish","format-standard","hentry","category-android-studio","category-archieve","category-tips"],"psp_head":"<title>How To Add\/Create Local HTML File In Android Studio \u2013 Abhi Android<\/title>\r\n<meta name=\"description\" content=\"We usually need HTML files for displaying your content in WebView. Here we will show how to create local HTML file in Android Studio.\" \/>\r\n<meta name=\"robots\" content=\"index,follow\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/abhiandroid.com\/androidstudio\/add-local-html-file-android-studio.html\" \/>\r\n","_links":{"self":[{"href":"https:\/\/abhiandroid.com\/androidstudio\/wp-json\/wp\/v2\/posts\/695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/abhiandroid.com\/androidstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/abhiandroid.com\/androidstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/abhiandroid.com\/androidstudio\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/abhiandroid.com\/androidstudio\/wp-json\/wp\/v2\/comments?post=695"}],"version-history":[{"count":1,"href":"https:\/\/abhiandroid.com\/androidstudio\/wp-json\/wp\/v2\/posts\/695\/revisions"}],"predecessor-version":[{"id":1466,"href":"https:\/\/abhiandroid.com\/androidstudio\/wp-json\/wp\/v2\/posts\/695\/revisions\/1466"}],"wp:attachment":[{"href":"https:\/\/abhiandroid.com\/androidstudio\/wp-json\/wp\/v2\/media?parent=695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/abhiandroid.com\/androidstudio\/wp-json\/wp\/v2\/categories?post=695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/abhiandroid.com\/androidstudio\/wp-json\/wp\/v2\/tags?post=695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}