Android Question Dirinternal max files inside!

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
Hi, I'm using SD Zip library
I tried to unzip a single file containing 500 images files to file.dirinternal folder directly.
All the tries i got only 9 files extracted! where are others?

Why?
Is their a limit here!
Or the problem is with sd zip library?
 

drgottjr

Expert
Licensed User
Longtime User
how much memory does the app/and the device have available at any given time? the archiver can only work with available resources. the zip file alone will occupy memory. and then there is the question of each image's size as it is expanded. you might want to couch the entire extraction operation in try/catch and see what error pops up. you can query available memory.

suggestions: break up your archive into smaller chunks. see how to extract to a real external sd card (if your device has one)
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
in looking at the source for the original ar.jar (not star dust's sd zip library), the expanded size of each zipped file is visible in one of the library's methods. that method returns a list (actually, a map) of the files in the archive, with each's so-called zipinfo. the 3rd field in that object is the expanded size. so it appears you would have a way of knowing the amount of storage you would need for your images before actually un-archiving them. match that with the amount of memory available, and you're good to go. or not. just fyi.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
this will get you the total size necessary:

if the zip is in your dirassets, copy it to dirinternal.
otherwise, download it and save it in dirinternal

load the archiver library from add'l libraries. (star dust's library may or may not expose the properties i'm using. i don't know)
EDIT: i took a look at the sd zip source. i did not see the expanded size anywhere.

ask the archiver for ListZipEntries
it's a map, even thought is says list
step through the map catching the expanded size of each file to be unarchived.
adding up the sizes as you go along
at the end, show the total size necessary.

i've run it and confirmed the output with a zip file i have.
the map's key is the file name. the associated value (fileinfo) is an array of 3 longs. the first element is the expanded size.
if you look at a zip file on your desktop, you'll see the expanded and reduced sizes are stored in the archive.
listzipentries() exposes those values.

B4X:
    dim ar as.archiver
    Dim filemap As Map = ar.ListZipEntries(File.DirInternal, "filename.zip")
    Log(filemap.Size & " entries")
    Dim totbytes As Long = 0
   
    For Each v As Object In filemap.Keys
        Dim bytes() As Long = filemap.Get(v)
        Log(v & " " & bytes(0))
        totbytes = totbytes + bytes(0)
    Next
    Log("total size necessary: " & totbytes)
 
Last edited:
Upvote 0
Top