How to access all file without unzip any zip file in android? - android

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.

Related

How does Google's APK Expansion Zip Library read zipped files without unzipping them?

Google provides APK Expansion Zip Library as a way to read file in zipped format. It creates a virtual file system for the zipped file. However, how could this possible?
Does it mean we can read file without unzipping it firstly? Or it just unzip the file when it's needed? I can't find any documentation on how it works
Does it mean we can read file without unzipping it firstly?
It depends what you mean by unzipping. Is there a process where the entire contents is decompressed with each individual uncompressed file stored on the device? No. It doesn't do that.
What happens is that when you read a bit of a file, then it'll inflate (unzip) a chunk that's big enough to satisfy your request.
Such an approach is OK for when you're just reading sequentially, but it's not going to be great at seeking. When you seek forwards, you're effectively going to be unzipping and discarding data, and seeking backwards looks like it isn't supported.
The other thing to bear in mind is that some file types are stored in the expansion apk without compression. This is useful for when you do need random access, or for filetypes that are already compressed (e.g. .mp3 files).

How can i insert a .bin created on desktop file into apk

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.

How to put a *.cfg file to the same directory as the *.apk file?

I am really new to android devices, we have got an app that needs to read a *.cfg file from the same place as the apk. So the question is:
1) When i attach my mobile-phone to the computer, can i put it from the explorer? If yes, how?
2) Is there a mechanism in Android, that looks for some kind of include directories
when opening a Program?
It would be great if you could give me a hint.
You'd want to drop the *.cfg files into the assets/ folder. Then the app will have access to those raw *.cfg files during runtime.
From Managing Projects
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.

how to read .webarchive file in android

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.

How to load an xml file from android's assets folder by name

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!

Categories

Resources