Load WebView with .html file linked to /assets folder - android

I need to load .html file into WebView but this file is situated in external folder on disk. I cannot copy file into /assets folder under my android project. But i can create a link to this file in Eclipse.
The question is how can i load this linked file into WebView?
I tried to load it with webView.loadUrl("file:///android_asset/myFile.html") but it did work. WebView cannot find 'myFile.html' in '/assests' folder. ('myFile.html' link in /assests folder to real file in external folder on disk.)
Please give any idea!!!!
Thanks in advance!

If you are on OS X or Linux, try creating a symlink into your project assets/ for the file in question. I doubt that an Eclipse link will be sufficient, as packaging assets into the APK is not Eclipse's job, and the Android tools invoked by Eclipse may not know about Eclipse links.

For windows use this command mklink /D link-folder-name target-folder. The eclipse/android work fine with this link and your apk will have all the linked resources.

Related

Why can't I see `assets` folder in my Android package installation folder

I'm browsing with DDMS my application's installation folder /data/data/com.my.app and I can't find where the assets folder is. I'm using it inside my application using URI file:///android_assets/...
I can't find where the assets folder is
That is because there is no assets folder on the device. The assets, like your resources, are packaged into the APK file. Assets are not unpacked as part of APK installation. file:///android_asset/, for those things that understand it, knows to look inside of the assets in your APK.

Android studio assets folder

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
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.

how to make copy asset folder in apk directory?

I am making hybrid application.I have one file in this directory assest->www->ATMS.html or other js files.So I load in web view like this.
web.loadUrl("file:///android_asset/www/a.html");
I want to copy all file files and folders which is inside the asset folder.Instead of loading from assest folder .I need to load from copy folder.As some some told me that there is file system of APK file.Mean we can copy all files in apk file system .and load html from that APK file system .
There is few link give information to copy of assest folder
How to copy files from 'assets' folder to sdcard?
But I don't get knowledge how to copy in APK file system .Mean when Aplication uninstall it remove the copied folder .When application launch it make copy of assest folder in apk file system ..
thanks
Not sure I get your question fully right as explanation is bit messy, but while APK is ZIP file, you should really consider it read-only. So you can copy files out of it but you cannot add anything to your APK nor alter it at runtime.

Can I convert .apk files to html5?

Can I convert .apk files to html5?
I need to modify an existing app, but don't know how to handle .apk.. if there is any tool that can covert it into html5 tht would save me.
Let me know..
Thanks.
An apk file is just a jar file for Android. You can unpack it using unzip, jar, etc., which will extract any HTML files within (if any).
If the app you're trying to work with isn't actually an HTML5 app, then there probably won't be any HTML files for you to play with. There is no automatic way to convert a native app to HTML5.
No, you can't, some tool can help you to decompile apk to java, but not HTML5
.apk files cannot be converted to .html files.
You cannot do it Straight away.. First you should get the Source Code of an APK then you should check whether the www or assets folder contains HTML Codes. If the App is created through PhoneGap you can do that.. Best of luck!
You can extract your apk file.
Then go to that folder and click on the assets folder in which you will find your www folder.
So in your www folder you will find your html, js, css files.
But the main thing is that
your project must be the phonegap project or hybrid project.
i tried using "apk editor.apk" and i also opened the assets folder and i saw a bunch of xml , html and some other files, then you can see some html5 files. here is the link to download apk editor
https://apkpure.com/apk-editor-pro/com.heagoo.apkeditor

How to add a file path for a file input stream in eclipse

I am using eclipse with the android adt. I am trying to initialize a file input stream, the file is in the workspace folder in the folder of my project. Now I have no idea what eclipse assumes to be the root of the project. I keep getting the file not found exception. I put the file in the src folder also and then in the src/com/.... in the folder with all the activity java files but in vain. I also tried giving the absolute path but i get an error:
/C:/Users/hp/Desktop/events.ics: open failed
I read similar questions but somehow, its not working. Any help is deeply appreciated.
I am trying to initialize a file input stream, the file is in the workspace folder in the folder of my project.
Your development machine is not an Android device. Hence, the file is not going to be in the filesystem of an Android device.
If you wish to package files with your app, you can do so as an asset or as a raw resource. You can read more about the assets/ and res/raw/ project directories in the documentation.

Categories

Resources