Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified
Accepted Solution

Unzip zip archive with sample - resource installer to SD Card

Some of you might have found this:

 

http://supportforums.blackberry.com/t5/Java-Development/Resource-Installer-to-SD-Card-Application-Sa...

 

In that, I said in one of the posts, that you needed to know what files were in your package, but added "see later". 

 

Finally, here is the "see later", which has been prompted by this Thread:

 

http://supportforums.blackberry.com/t5/Java-Development/Searching-a-way-to-manipulate-7-zip-zip-and-...

 

The attached file is a zip archive.  Please unzip it and you will find a JDE project.  In that project there is some code and another a zip archive.  The code processes the internal zip archive, reading the directory and writing all the files from the archive to the SD Card. 

 

This I think is useful in itself - you could use this project, stick you own zip archive in it and you have an installer!

 

And I suspect the Unzip code contained might be useful too.  This uses the native decompression built in to the Blackberry, so is as fast as it can be. 

 

I actually use a zip archive as a repository for data, so that in some applications, the archive is never actually unzipped, it is just copied to the SD Card and left there as an archive. 

 

My testing suggested it was actually faster to leave the zip archive intact and process files directly from it, rather than unzipping and processing the files on the SD Card.  In my testing, it seemed that there was a load of overhead associated with opening (or perhaps finding) each file on the SD Card - this is removed using the Unzip processing because the SD Card file (i.e. the archive) is only opened once.

 

It has actually been waiting for me to find an excuse to publish, I am sorry it has taken so long.

 

Also apologies, this is a JDE project. 

 

This code is offered with no support, you are on your own.  But I can assure you that there are applications on App World using this code.  And I will try to answer questions. 

 

And most importantly it is offered free, without any reservation.  And while there are parts that look like Java ZIP Library and zipme - this is because I was looking for a good architecture.  It is my own code.  So copy and paste to your heart's content.  No need to credit me, it can be all your own work if you want! 

 

Enjoy....

Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700

Re: Unzip zip archive with sample - resource installer to SD Card

Hi Peter.

Trying to test the project.

 

I imported the project to Eclipse, no problem.  Cleaned it and packaged it, no problem.

 

Tried to run it on a simulator. Got uncaught excption before any screen showed.  Run it in debug and got this message:

 

Error starting com_sample_install_Installer: Module 'com_sample_install_Installer' has verification [0.0] error 2618 at offset 002d (codfile version 78)

 

I used API 5.0

 

Any suggestion?

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Unzip zip archive with sample - resource installer to SD Card

Make a change and rebuild it. 

Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700

Re: Unzip zip archive with sample - resource installer to SD Card

Peter.

 

Tried that. Did not help. Did not make a change on all classes but a few.  Clean all and package.

 

It is not a problem for me any more. I just picked the classes I needed for a background unzip and added code to transfer the zip file from a website to theSD card. Also created a stripped down version of the UnzipRunnable that is not a thread since the calling class is threaded anyway.

 

Works nice, thanks a lot

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Unzip zip archive with sample - resource installer to SD Card

OK, that works for me!

 

Can you tell me the Eclipse level, plug-in level and OS level you were compiling against?  I might (given time) attempt to replicate.  I think the project was originally built in JDE actualy so perhaps I should rebuild in Eclipse anyway.... 

Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700

Re: Unzip zip archive with sample - resource installer to SD Card

Hi

Eclipse Juno, Service Release 1.jde and jre 5.0

 

Having some problem with a bit "complicated" structure of the zip. It contains one folder and that folder contains 2 files and a second folder. The second folder contains a number of files as well as a number of folders containing files.

 

I have made some changes in the code so maybe that is causing it to only unzip one of the foilders on the second level. Have to walk thru it

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Unzip zip archive with sample - resource installer to SD Card

"Having some problem with a bit "complicated" structure of the zip"

 

The code should cope with that, but you need to detect the directory component in the file name.  Also I seem to remember that some zip creators put 'directory' entries in the zip archive.  These entries contain no data, they are useful so that a zip archive can be unzipped and still cr3ate empty directories.  I am not sure that I have ever tested these because nothing I have used this code for did that. 

Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700

Re: Unzip zip archive with sample - resource installer to SD Card

My error!

Code error elsewhere.  Everything extracted properly it seems.

 

Thanks a lot a gain!

 

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Unzip zip archive with sample - resource installer to SD Card

OK, since I know this code has been used by someone else, I think I will mark this Thread as solved.  Agreed?

Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700

Re: Unzip zip archive with sample - resource installer to SD Card

Absolutely. When time permits check out why an import to Eclipse causes trouble.


Did not see a "solved" button or choice anywhere otherwise I would have done it

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-