i developing android app needs select files storage system , zip up, have command run on it.
i've tried picking files using following code:
intent intent=new intent(); intent.settype("image/*,video/*"); intent.putextra(intent.extra_allow_multiple, true); intent.setaction(intent.action_get_content); startactivityforresult(intent.createchooser(intent,"select picture"), 1);
can me on how this?
file selecting code looks fine. here example of it. see link. android have huge native support zipping , unzipping file. here examples might you.
zipping file
public void zip(string[] _files, string zipfilename) { try { bufferedinputstream origin = null; fileoutputstream dest = new fileoutputstream(zipfilename); zipoutputstream out = new zipoutputstream(new bufferedoutputstream( dest)); byte data[] = new byte[buffer]; (int = 0; < _files.length; i++) { log.v("compress", "adding: " + _files[i]); fileinputstream fi = new fileinputstream(_files[i]); origin = new bufferedinputstream(fi, buffer); zipentry entry = new zipentry(_files[i].substring(_files[i].lastindexof("/") + 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(); } }
Comments
Post a Comment