Android decompress RAR files programmatically
<p>Is there a way to decompress rar files in android 1.6 programmatically?</p>

<p>I've already tried JUNRAR but got some exceptions...</p>

<p>Here's my code, after successfully opening rar file, using junrar library:</p>

<pre><code>FileHeader fh=null;
  while(true)
  {
   fh=rar.nextFileHeader();
   if(fh==null) return false;    
   if(fh.isEncrypted()) continue;     
   //check file

   if(!fh.isDirectory() &amp;&amp; fh.getFileNameString().toLowerCase().endsWith(".jpg")) 
   {
    try 
    {
      File f=new File(tmppath+covername);      //name of the destination file

      OutputStream stream = new FileOutputStream(f);            
      rar.extractFile(fh, stream);         //call junrar    

      stream.close();
      return true;
     } 
     catch (FileNotFoundException e1) 
     {
        // TODO Auto-generated catch block
         return false;
     }
     catch (RarException e) 
     {
      // TODO Auto-generated catch block
         return false;
     } 
     catch (IOException e) 
     {
        // TODO Auto-generated catch block
         return false;
     }    
   }
</code></pre>

<p>And DDMS perspective show this exception...?</p>

<pre><code>ERROR/AndroidRuntime(2733): Uncaught handler: thread Thread-9 exiting due to uncaught exception

ERROR/AndroidRuntime(2733): java.lang.VerifyError: de.innosystec.unrar.unpack.ppm.SubAllocator

ERROR/AndroidRuntime(2733): at de.innosystec.unrar.unpack.ppm.ModelPPM.&lt;init&gt;(ModelPPM.java:73)

ERROR/AndroidRuntime(2733): at de.innosystec.unrar.unpack.Unpack.&lt;init&gt;(Unpack.java:43)

ERROR/AndroidRuntime(2733): at de.innosystec.unrar.Archive.doExtractFile(Archive.java:456)

ERROR/AndroidRuntime(2733): at de.innosystec.unrar.Archive.extractFile(Archive.java:440)

ERROR/AndroidRuntime(2733): at com.pmc.myRar.unrarCover(myRar.java:164)

ERROR/AndroidRuntime(2733): at com.pmc.myDataBase.addRar(myDataBase.java:541)

ERROR/AndroidRuntime(2733): at com.pmc.libraryActivity.addtoDB(libraryActivity.java:306)

ERROR/AndroidRuntime(2733): at com.pmc.libraryActivity$2.run(libraryActivity.java:240)

ERROR/AndroidRuntime(2733): at java.lang.Thread.run(Thread.java:1060)
</code></pre>

<p>Thanks,
pmc</p>
