It has been a long time to find out what the customer needs to achieve, ZIP folder decryption, and functions, and this information is really scarce. Post the source code to share with you.
Package com. hongan. test;
Import java. io. File;
Import android. app. Activity;
Import android. OS. Bundle;
Import android. util. Log;
Import android. view. View;
Import android. view. View. OnClickListener;
Import android. widget. Button;
Public class PassWordZipDemoActivity extends Activity {
/** Called when the activity is first created .*/
Button btn_jiemi, btn_jiami;
ZipFileWithPassword zipFileWithPassword;
String filePath;
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );
Btn_jiemi = (Button) this. findViewById (R. id. jiemi );
Btn_jiami = (Button) this. findViewById (R. id. jiami );
ZipFileWithPassword = new ZipFileWithPassword ();
Filepathappszipfilewithpassword.zip Dir;
Btn_jiemi.setOnClickListener (new OnClickListener (){
Public void onClick (View v ){
// TODO Auto-generated method stub
ZipFileWithPassword = new ZipFileWithPassword ();
ZipFileWithPassword. newFolder ();
ZipFileWithPassword. TestDecryptZipFile ();
}
});
Btn_jiami.setOnClickListener (new OnClickListener (){
Public void onClick (View v ){
// TODO Auto-generated method stub
ZipFileWithPassword. TestEncryptZipFile ();
File file = new File (filePath );
Log. I ("infor", "filePath is" + filePath );
DeleteFile (file );
// File. delete ();
}
}); Www.2cto.com
}
Private void deleteFile (File file ){
If (file. exists ()){
If (file. isFile ()){
File. delete ();
} Else if (file. isDirectory ()){
File files [] = file. listFiles ();
For (int I = 0; I <files. length; I ++ ){
This. deleteFile (files [I]);
}
}
File. delete ();
} Else {
Log. I ("infor", "the deleted file does not exist! "+ '\ N ');
}
}
}
Demo source code
Author: awp258