Load html files from raw folder in web view

unflagged.destination picture unflagged.destination · Jan 5, 2013 · Viewed 22.6k times · Source

How to load html files in WebView from raw folder. I don't know how to add the path of these html files in WebView.loadData() function. I know how to load file from asset folder in WebView but here getting problem with raw folder.

Thanks in advance

Answer

Dixit Patel picture Dixit Patel · Jan 5, 2013

Use this code for Load html files from raw folder in web view:

For more information see the javadoc for WebView:

     public class ViewWeb extends Activity {  
            @Override  
            public void onCreate(Bundle savedInstanceState) {  
                super.onCreate(savedInstanceState);
                setContentView(R.layout.webview);  

                WebView lWebView = (WebView)findViewById(R.id.webView);
                lWebView.loadUrl("file:///android_res/raw/your_file_name.html");
            }  
        }