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.

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

    File directory = new File(Environment.getExternalStorageDirectory(),getString(R.string.app_name)); if(!directory.exists()) { directory.mkdir(); } File f = new File(directory, ZIP_FILE_NAME); return f; } public String getDateName() { Date date = new Date(); String format = "yyMMddHHmm"; SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US); String dateString = sdf.format(date); String fileName = "Example" + dateString; return fileName; } final String zipFile=createZipFile().getAbsolutePath(); String fileName[] = new String[]{}; fileName=new String[]{image1,image2,image3,image4}; Compress compress=new Compress(fileName, zipFile);

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: