-1

when i try to create a webView in android studio and point it here: file:///src/main/assets/www/index.html, it keeps saying that it can not find the file path.

Thanks in advance.

Mitch

1 Answers1

0

Use file:///android_asset/www/index.html. There is no src/main/assets/ directory on the device -- that is simply how your project is structured. Assets are packaged as part of the ZIP archive that is the APK file; file:///android_asset/ is a means for WebView to pull from the project assets.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • so, do i create a folder called assets under app? – mitchell anderson Sep 03 '14 at 23:29
  • @mitchellanderson: No, you keep them right where they are. The problem is in your Java code, not where the files reside. – CommonsWare Sep 03 '14 at 23:30
  • @mitchellanderson: Then I don't know what to tell you. If you have `app/src/main/assets/www/index.html`, and you use `loadUrl("file:///android_asset/www/index.html")`, it should work. – CommonsWare Sep 03 '14 at 23:33
  • Maybe post your code @mitchellanderson. Are you in an Activity or a Fragment or some other class? There are a number of things which could affect your outcome. – CodeMonkey Sep 03 '14 at 23:35
  • @mitchellanderson: That seems fine. Depending on what is in the HTML, you might need the `INTERNET` permission (e.g., if it is trying to load CSS off of a Web site). What specifically are your symptoms? – CommonsWare Sep 03 '14 at 23:45
  • i just have a

    tag and am linking to javascript and CSS files that are in the same directory as teh index.htlml

    – mitchell anderson Sep 03 '14 at 23:47