Extracting a sub file from a zip file - android

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!

Related

How to provide a text file within an Android app?

Where do I put a text file that I want deployed with my app such that I can provide within my app a path to that text file. I have an included JNI library which will take the text file at that path and perform actions on it. So in other words, I don't think I can just put it in my assets folder without reading the file and resaving it to SD card or something (as I don't think you can reference an assets file directly by path right?). Is there a way around this?
You can place files in res/raw/ and read them as raw resource files/streams.
See https://stackoverflow.com/a/15934525/5734895 for reading raw resources.

Where can I see the file in path getApplicationContext().getFilesDir()

I am using the below code to create a file in android as
File file = new File(getApplicationContext().getFilesDir(), "content.txt");
I want to open the file in my phone. I went to the path
Local storage/Android/data/<my package>/files/
However, I cannot see the file. My Android version is 5.0.1. What is happen? One more thing, Do you think the above way is a good way to save file? What is common path to save a file in Android? Thanks
The file locates in /data/data/[your package]/files,it's app private directory.
It's a good way or not depends on the purpose of your file.
if you want your file visable only to you(the app developer),the folder is right
if the file can be visable to others and the file is large,then you can put it to sdcard folder
if you want the file stay even if your app being removed,you shouldn't put it in this folder.Because when an app removed,the all data in /data/data/[package name]/ will be deleted also.
You find in:
/data/data/[your package name]/files/

Add file in apk so that user can access it?

I want to add my one file (example mp3) inside an apk so that when user start that application for the first time it should copy that file into phone memory.
Can someone give me some suggestions regarding how to do this?
Try putting the mp3 file in the assets/ folder. if your project doesn`t have one, create one on the same level as your res/ folder. Then, when the app runs, save the file to the sd card.
Have try to put your file into raw or asset folders.because when AAPT packaging for .apk with .class then its focuse goes to res folders and then at last to manifest file...so when you puts your file into these folders then these files takes their space into .apk.
And use a variable to know your Application is installed for very first time then make folders(where you want) to copy that file...

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 access all file without unzip any zip file in 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.

Categories

Resources