Download zip file using HTTPPOST in Android :

Step 1 :

Create an Asybktask

new save().execute();

Step 2:

In Asynktask

public class save extends AsyncTask<String, Integer, byte[]> {
protected void onPostExecute(byte[] result) {
byte[] data;
protected byte[] doInBackground(String... arg0) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(URL);
try {
MultipartEntity entity = new MultipartEntity();

//Add required post data
entity.addPart("id", new StringBody("1"));
entity.addPart("api_key", new StringBody("key"));
entity.addPart("api_password", new StringBody("password"));

//Execute post method

//Read the response
HttpResponse response = httpclient.execute(httppost);
 InputStream input = response.getEntity().getContent();
data = new byte[input.available()];;
File path = new File(Environment.getExternalStorageDirectory()+"/");
if (!path.isFile()){
OutputStream outputStream =
new FileOutputStream(path);

int read = 0;
byte[] bytes = new byte[1024];

while ((read = != -1) {
outputStream.write(bytes, 0, read);
} catch (ClientProtocolException e) {
} catch (IOException e) {
return data;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s