Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open html file located inside my application using WebView

I am just started Android application development. Here i have a simple Activity which contains a WebView. It works fine when i try to open a website (like http://www.google.com). But i want to open a html file (assume index.html) file which i created in my application's 'res' directory. Full path is 'res/base/index.html'. Then how to open this file in my WebView.?

Working :

webview.loadUrl("http://www.google.com");

Not Working :

webview.loadUrl("./res/base/index.html");

Please help me. :)

like image 330
Jithesh Kt Avatar asked Oct 29 '12 17:10

Jithesh Kt


1 Answers

Put the file in your /assets directory and use:

webview.loadUrl("file:///android_asset/index.html");
like image 165
Raghav Sood Avatar answered Oct 20 '22 21:10

Raghav Sood