how to use android_asset - android

I try to make Webview from to display application/x-shockwave-flash embed element in my app, but i have blank gray screen on emulator and white on device. There are many topics about this problem but any1 really solved.
I explore log of simillar app and see: file//android_asset/index.html. So question... this static file or i can get it from web or modify it.
I trying get my data video.loadDataWithBaseURL() from web, but can i have that data from local storage?
Maybe I said something wron but it's look for me like 'convert web data to local'?? Can some one help my in my problem or explain in this question.
Thank you.

file://android_asset/ is a way that allows android apps access assets by a network-based URI. But assets represent neither local nor online files, they are packed into your apk. Put any files in assets folder in a android project and they will be packed into the apk file by the builder.

Related

where to place the html,java script files other than assets in android

can we add the html and java script code anywhere other than assets folder in android which will used in web View, and it cannot be a URL also since it should work offline, because when we place the .html,java script etc in assets it can be easily found when we unzip the apk.
Kindly advice me in this regard.
Thanks
Nagendra.
You can put them in drawable or values folder as well.
Yes you can put them in /drawables/raw folder and you can access them like mentioned in Load html files from raw folder in web view. If you talk about unzipping or even reverse engineering for that matter, the java code, layout files all can be reverse engineered, sometimes even if you obfuscate the code. I would suggest you to store all sensitive data on a servers and then get it on runtime in the app.

Android Asset folder image automatically copying to gallary

Greetings dear readers,
I have this query which the team is facing. We are developing a hybrid app for android platform and ran into one issue that seems to get complicated.
Here it goes.
Team is calling static HTML pages(no control on html content modification) in a web view, the html page content involves images which are taken from asset folder. Now when we are debugging the application on android device, asset folder images are getting copied automatically in gallery.
I am not a native coder but it seems asset folder images will be copied automatically. Please correct me if I am wrong. Is there any way, When I debug my app on device I could restrict this automatically copying of asset images to device gallery.
As I am not from Android, this might be the silly question but any help in this scenario would be highly appreciated.
I have researched on google to find out possible fix but unable to find one.
Guys, please suggest.....Any leads on this....
If you don't want your photos being accessible from gallery, add .nomedia file to the folder copied onto the device. This will prevent photos from appearing into gallery.

What are the file formats in Android WebView cache directory (data_1, f_000001 etc.)?

I created a rudimentary browser with help of a WebView.
When I visit a website (containing some text and a few images), the cache directory in /data/data/com.mayexample/cache/webViewCacheChromium gets filled with a few files called index, data_0, data_1, data_2, f_00001, f_00002 etc.
I was wondering, what's the format of these files, what do they contain? I thought about "so, a few of these files surely have to be the website's images then" and tried opening them in a file manager (open as image). But whatever file I pick, the process says "Failed loading!". Even if I rename some of them to .jpg, still I can't open anything.
I have read on the internet that this worked for some people though (look at Android WebView - Load Images from cache, it's exactly what I want to do), but I can't do anything with the cache's files.
Do you know a way to open webview cache files? Doesn't one file represent a corresponding cached image for example?
What I really want to achieve (once I understand the structure of the cache files) is to programmatically fetch images of the webview from it's cache, like the author of the link posted above (unfortunately this posting's answers don't help much)
Thanks!
The cached files might be one of the CSS, or JS/image/html types. On earlier Android releases, one cached file maps exactly one CSS or JS/image/html file.
As far as I know the Browser engine (actually the HTTP module) maintains such cached files in a URL-to-HashKey manner. So what you found (such as "4f42185de3a3a461_1") may be associated with any web resource files such as JS/CSS/images/HTML, etc.
I remember WebView used to store such URL-to-HashKey mapping data in sqlite3 tables in earlier Android versions.
The problem here is you have no idea about the mapping relations so you can hardly retrieve the file you want. A tricky way is to read the AOSP source code then you may be able to know how the generate the HashKey by an unique URL, or you can manipulate the sqlite3 tables, if there are still any on Android 4.4.
I was able to view files in the webViewCacheChromium folder using this tool designed for the Chrome desktop browser:
http://www.nirsoft.net/utils/chrome_cache_view.html
The contents are basically what you'd expect for web cache - images, javascript, css, html.

Separating images from the apk file in android

I am writing an android application which has a lot of images in it.
I do not want to keep these images as a part of my apk file because that will make the size of the apk file very huge.
I have written the application in a way that it loads these images at runtime from the sdcard from some predefined location. Now my problem is that how do i provide these images to the user who wants to install my application. Since the images are not a part of the project (i.e. not present in any of the drawable folders) so they will not be a part of the APK file that i provide.
Is it even possible to do such a thing in Android? Or can someone suggest a better solution that i have right now. Any help is greatly appreciated.
There is an official way to achieve what you want: APK Expansion Files

Storing lots of small web pages on Android

I'm developing an application that uses about 150 small HTML pages (up to 25-30kb, actively used by WebView).
My question is how to save this kind of data on Android device ?
Maybe XML or SQLite......
Thanks
Put all the pages in Assets folder. They will be packed together in the apk and access them as below:
webview.loadUrl("file:///android_asset/your_html_page.html");
You can write them at runtime into a specific directory in the sdcard (if present) and load them from it when you want...

Categories

Resources