I am developing an android application, that should open html 5 file when it launches. What I did was
- I saved the complete html application under android Assets folder.
-
I am not able to run the html file in the external browser using the path of assets folder directly, Following code which I used
Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("file:///android_assets/mobile/index.html")); startActivity(browserIntent);
An exception is thrown.
- I send this folder to phone’s internal memory and From there I want to run it.
Qn 1. How can I send a file into phone memory?
Qn 2. And can I run that html file from phone memory?
Is it possible to do so??
First, use
file:///android_asset/mobile/index.htmlinstead. While the directory on the filesystem isassets/(plural), the URL format usesasset(singular).Second, you cannot open a Web browser on one of your assets. You will need to either:
Copy the files to external storage and launch the default browser on them
Copy the files to internal storage, create a
ContentProviderto serve them, and launch the default browser on the resultingcontent://pathThis sample project demonstrates the second approach, albeit using a single PDF file than a directory of assets.
A third possibility is for you to display the contents yourself using a
WebViewwidget.