WebView local html

Put your problem here if it does not fit any of the other categories.

WebView local html

Postby ulatec » Mon May 31, 2010 6:56 pm

Within WebView, is it possible to to link a local html file that will be packaged within the apk?

If not within the WebView is there another method to display a local html file?

-Thanks :D
ulatec
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sat Mar 27, 2010 2:09 am

Top

Re: WebView local html

Postby ulatec » Mon May 31, 2010 7:35 pm

Sorry, I have answered my own question and have found the answer :) Please close :)
ulatec
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sat Mar 27, 2010 2:09 am

Re: WebView local html

Postby paradroid666 » Tue Jun 01, 2010 9:17 am

would be nice to share your answer.... the best search for a problem doesn't if there is no answer...
paradroid666
Junior Developer
Junior Developer
 
Posts: 20
Joined: Fri May 21, 2010 2:36 pm

Re: WebView local html

Postby ulatec » Wed Jun 02, 2010 4:50 am

Sure, I would have no problem in explaining the solution :)

The solution is quite simple to begin with,
file:///android_asset/alchemy.html
Code: Select all
       
        webview = (WebView) findViewById(R.id.webview);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.loadUrl("http://www.google.com/");


We can simply change our URL, which was my initial thought, but just couldn't seem to figure out how to point to the correct directory.
Code: Select all
        webview = (WebView) findViewById(R.id.webview);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.loadUrl("file:///android_asset/alchemy.html");

This code will point to the html file "alchemy.html" in the Assets folder of your project.
ulatec
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sat Mar 27, 2010 2:09 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 20 guests