Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

load somefile.html file from internal storage to a webview of an app

I have a file in the internal storage of my tablet. /myfolder/subfolder/index.html. How can i load this into a webview of an app.

i have tried

 webview.loadURL("file:///myfolder/subfolder/index.html"); 

but it is not giving the expected result. it says web page not available.

I know how to load from the asset folder or from the web/internet. but i need to load local file into webview. is it possible.?

like image 274
SKK Avatar asked Jan 31 '13 11:01

SKK


2 Answers

File file = new File("/data/data/packagename/foldername/");
webView.loadUrl("file:///" + file);
like image 134
duggu Avatar answered Nov 13 '22 12:11

duggu


I was able to solve my problem by using the following as path:

webview.loadURL("file:///mnt/sdcard/myfolder/subfolder/index.html");
like image 30
SKK Avatar answered Nov 13 '22 12:11

SKK