I have a requirement like this. I want to read .webarchive File. I have one file with .webarchive extension and i have put that file in asset folder. I want to read that file on android webview. Is it possible?
I googled and found some useful link. This git content is really helpful.In this what it does is, put extracted content of .webarchive file in asset folder and from there data is shown on webview. My query is that i don't want to put extracted content in asset. I have file in .webarchive extension and want it to be opened directly in webview.
i guees zipInputStream is just for file name with zip format extension,and another thing is that i read some where that only that zip files will be extracted with ZipInputStram which have been zipped with WinRar Software,Well in my case what i tried is I have tried to unizip webarchive file with follwing method http://pastie.org/8516247 and here is a log what i am getting
http://pastie.org/8516249,
now from this log you can see command is not even entering inside the while loop at line number 6 which is proved by this:
log 11-29 13:01:46.903: V/Decompress(19936): 1
And if i am using any zip file inplace of test.warc at line number 4 than command is entering in while loop,that means this ZipInputStream is completely ignoring .WARC file,isn't it?
So if any one have idea how to extract .webarchive file or read .webarchive file without extracting it than please help me.
If any one having idea then please help me
Thanks
WebKit Bugzilla
Bug 42716 – Implement WebArchive for Android
That was RESOLVED WONTFIX in 2012.
Still, what's there could be a good starting point, or point of continuation towards an acceptable answer to this question.
Related
I have code for creating an internal file, there is random algorithem that create the data stored in it and i want any app to have the same file with the same binary data in it.
so i need to make the file on my desktop and add it to internal files some how.
my question is what do you think is the best way to do it.
i thought to locate it in my project, read it, and write it to internal files.
the problem is, i dont know where to locate my file in android studio so that it will be included in the external files and then where to read it from.
thanks. =]
hope i made myself clear.
Put it in src/main/assets/.
You can then access your file with AssetManager and do whatever you want with it.
From the Android Developers website:
main/assets/
This is empty. You can use it to store raw asset files. Files that you
save here are compiled into an .apk file as-is, and the original
filename is preserved. You can navigate this directory in the same way
as a typical file system using URIs and read files as a stream of
bytes using the AssetManager. For example, this is a good location for
textures and game data.
You need to move that into the assets folder. From there you can refer to the file.
I am working on reading epub3 file and i want to access all files which used for create epub3 without *unzip it.*
any suggestion or solution would be appreciated....
I have tried to solve this and i got the following solution.
Zip is a one type of file Which include many directory and files so we can't get it in directory and file format.
We can only get it in Bytes. Which is unused.
So we Have To Unzip it.....
Because Whenever we unzip it, then itself make one type of directory of sub directory and files So then we can access it in directory and file format.
While you can technically read the bytes from the zip archive without decompressing them, it will not help you as the data will be unusable in any epub display.
When a file is zipped, it is compressed using compression tables. This alters the data of the file, and to get back the original data you must decompress, or unzip, it first.
This is virtually no way to access files without unzipping. However, there is a way for targeted unzipping, i.e. unzipping a specific file instead of entire zipped folder. If that sounds good, you could probably go for Objective zip project.
P.S: Even i was working on a epub3 reader and I had to unzip the entire folder. Let me know if you find a better work around.
I have a number of image files in a zip file (more than 50,000). How can I get a file through its name in a zip file without extracting the whole zip?
Are you asking for to do this programmatically or manually ?
If you want to do it programaticaly you can use the ZipInputStream and iterate over your files and exact only the ones you want.
Take a look at the following post for some examples.
How to unzip files programmatically in Android?
Root explorer allows you to open the .zip file without extracting it then just go through it and find the image you want click and hold on it and click extract!
I'm trying to simply get the filename of a file from an online directory. The directory only has one file in it. The filename is actually the version number. If the filename is "newer" than the file that I already have stored on the android, it will download the file and replace it. I already know how to download the file. I'm not sure if android has some sort of built-in directory lister or if I need to create a PHP file that will display the files, then somehow open and read that in and use that as my path. Any help would be greatly appreciated.
You'll want to write that PHP script to return the file name. With that, you can do a straight download from the server.
I am trying to load an xml file located in the /assets folder of an android project by name using this method:
getAssets().openXmlResourceParser("thefilename.xml");
However, executing this code always throws a "FileNotFound" exception, even though the file is located in the /assets folder and is with the correct file name.
Now, I have not put the file in the /res/xml folder because I really need to be able to 1. edit the file right on the device itself and most importantly 2. add new xml files to the application without issuing an update, to allow for easy user modifications.
Thanks in advance.
I think what you are looking for is either getAssets().open("thefilename.xml") or getAssets().openFd("thefilename.xml") depending on what the end use of the file is. You can see from Dianne's response in this post awhile back that openXmlResourceParser() is not really usable just to gain access to files in the assets/ directory: http://goo.gl/2KfgT
From there you will have a stream that you could feed into a SAXParser or do whatever else you choose.
Side Note: On the points you mentioned you really can't edit files directly in assets/ or add new files to assets/ at runtime. You will need to work with files on either internal or external storage to do those things. You probably already knew that, but I thought I'd mention it.
Hope that Helps!