Kaan Soral
Kaan Soral

Reputation: 1645

Local files are innaccessible from an external url using PhoneGap on Android

<img src="file:///android_asset/www/images/image.png" style="border: black dashed 2px"/>

This line of code works as expected on a local html file.

However when you open an external url inside the app. (For example http://www.example.com/mobile/) The same line of code doesn't show an image.

To be clear, I am trying to access local files from an external url, because there are some JS files that are huge and It will be a waste of bandwidth to download them externally.

Upvotes: 2

Views: 1387

Answers (2)

suraj jain
suraj jain

Reputation: 1032

As @simon said u wont be able to load local assests on external url.. At best u can use loadDataWithBaseURL which will load your html with imgs/css/js from local assets folders something like this

webView.loadDataWithBaseURL("file:///android_res/raw/", html, 
                        "text/html", "UTF-8", null);

Upvotes: 1

Simon MacDonald
Simon MacDonald

Reputation: 23273

The remote site will never be able to load an image from the file:// protocol.

Upvotes: 1

Related Questions