Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create zip file in android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.77k
    Comment on it

    Here I am writing code to create zip file in android application.
    Here, First I create directory where I create zip file.
    Then by using Compress class I create zip file having some valid images already saved on our device.

    1. private File createZipFile() {
    2. ZIP_FILE_NAME = getDateName() +".zip";

    3.  
    4. File directory = new File(Environment.getExternalStorageDirectory(),getString(R.string.app_name));

    5. if(!directory.exists())
    6. {
    7. directory.mkdir();
    8. }
    9. File f = new File(directory, ZIP_FILE_NAME);
    10. return f;
    11. }
    12. public String getDateName() {
    13. Date date = new Date();
    14. String format = "yyMMddHHmm";
    15. SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
    16. String dateString = sdf.format(date);
    17. String fileName = "Example" + dateString;
    18. return fileName;
    19. }
    20. final String zipFile=createZipFile().getAbsolutePath();
    21. String fileName[] = new String[]{};
    22. fileName=new String[]{image1,image2,image3,image4};
    23. Compress compress=new Compress(fileName, zipFile);

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: