title: how to send zip files with intent? android
body: <p>I have the code bellow to compress what I want.</p>
  
  <pre><code>    public class JCreateZIP {
  
      private static final int BUFFER = 80000;
  
      public int zip(List&lt;String&gt; _files, String zipFileName) {
          try {
              BufferedInputStream origin = null;
              FileOutputStream dest = new FileOutputStream(zipFileName);
              ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
                      dest));
              byte data[] = new byte[BUFFER];
  
              for (int i = 0; i &lt; _files.size(); i++) {
                  Log.v("Compress", "Adding: " + _files.get(i));
                  FileInputStream fi = new FileInputStream(_files.get(i));
                  origin = new BufferedInputStream(fi, BUFFER);
  
                  ZipEntry entry = new ZipEntry(_files.get(i).substring(_files.get(i).lastIndexOf(File.separator) + 1));
                  out.putNextEntry(entry);
                  int count;
  
                  while ((count = origin.read(data, 0, BUFFER)) != -1) {
                      out.write(data, 0, count);
                  }
                  origin.close();
              }
  
              out.close();
          } catch (Exception e) {
              e.printStackTrace();
          }
          return 1;
      }
  
      private void dirChecker(String dir) {
          File f = new File(dir);
          if (!f.isDirectory()) {
              f.mkdirs();
          }
      }
  
  public List&lt;String&gt; getListFiles(File file, List&lt;String&gt; files) {
      File[] dirs = file.listFiles();
      String name = "";
      if (dirs != null) {
          for (File dir : dirs) {
              if (dir.isFile()) {
                  name = dir.getName().toLowerCase();
                  if(name.endsWith(".png") || name.endsWith(".jpg")) {
                      files.add(dir.getAbsolutePath());
                  }
              } else files = getListFiles(dir, files);
          }
      }
      return files;
  }
  
  }
  </code></pre>
  
  <p>This code executes when a button (Share) is clicked. Check the code bellow. </p>
  
  <pre><code>    String folderPath = Environment.getExternalStorageDirectory() +          File.separator + "Folder" + File.separator;
              String zipFile = "Item.zip";
              File dir = new File(folderPath);
              List&lt;String&gt; listFiles;
  
              JCreateZIP zipManager = new JCreateZIP();
  
              listFiles = zipManager.getListFiles(dir, new ArrayList&lt;String&gt;());
  
              if(zipManager.zip(listFiles, folderPath + zipFile) == 1) {
                  Toast.makeText(getApplicationContext(), "Item.zip created!", Toast.LENGTH_LONG).show();
  
                  Intent sendIntent = new Intent();
                  sendIntent.setAction(Intent.ACTION_SEND);
                  sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(folderPath));
                  sendIntent.setType("application/zip");
                  startActivity(sendIntent);
              }
  </code></pre>
  
  <p>But when I try to send the folder.zip by email, bluetooth or gdrive doesn't work. What can I do? </p>