I want to create a simple web based application on Android that loads certain large files, like Javascript and user interface elements locally, from ‘assets’ directory. However I am unable to use local assets directory when loading external HTML. So the external server would give something like this:
<script type="text/javascript" src="file:///android_asset/javascript.js"/>
And WebView would use that, even if the website itself came from external website. I know there are security risks involved, but is there a way to perhaps do that by only allowing specific URL’s on applications end?
Is there any way I can do that?
First of all you have to copy all the assets somewhere (external storage, for instance).
Then, to filter URL’s you should override method
in WebViewClient class.
added:
When your application starts, put the assets to /sdcard/somefolder/ see getExternalFilesDir()
in shouldOverrideUrlLoading override url to something like this
it should be as easy as