Android Webview loadUrl works but not loadDataWithBaseURL -


i have files downloaded app's storage @ file:///data/data/<myapp>/files/folder/. files downloaded folder include html, css, js , image files. when using webview's loadurl, following code works me:

webview.loadurl("file:///data/data/<myapp>/files/folder/filename.html"); 

but need download html file because need encrypt before storing it. problem not encrypting information (at moment). trying download html content string , use webview's loaddatawithbaseurl load webview. when trying this, getting "uncaught syntaxerror" , "uncaught referenceerror" web console. i'm not sure these errors coming from.

i'm using following code download html string:

url url = new url("myserver/filename.html"); inputstream input = null; input = url.openconnection().getinputstream(); bufferedreader br = new bufferedreader(new inputstreamreader(input));  stringbuilder sb = new stringbuilder(); string line; while((line = br.readline()) != null){     sb.append(line) }  string myhtml = sb.tostring();  

now when go load webview loaddatawithbaseurl:

string baseurl = "file:///data/data/<myapp>/files/folder/";  websettings settings = webview.getsettings();     settings.setjavascriptenabled(true);     settings.setpluginsenabled(true);     settings.setjavascriptcanopenwindowsautomatically(true);     settings.setlayoutalgorithm(layoutalgorithm.normal);    webview.loaddatawithbaseurl(baseurl, myhtml, "text/html", "utf-8", null); 

but when execute code, "uncaught syntaxerror" , "uncaught referenceerror". confused because if loadurl works fine, why isn't loaddatawithbaseurl acting in same behavior? because i'm not converting html string correctly? or html code itself?

turns out html coding error. above method works fine if trying download html.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -