title: Android partial download http
body: <p>In my application I download media from server via HTTP connection. While downloading if connection is break anyhow (say, no n/w, permission revoke), File get downloaded partially.</p>
  
  <p>Earlier we are deleting the file and downloading it from the scratch.</p>
  
  <p>Now, the requirement is changed. I have to continue from where I left (like in WhatsApp).</p>
  
  <p>So what I am doing is checking the file existence and if file exist skip the stream. Please find the below code snip.</p>
  
  <pre><code>InputStream is = con.getInputStream();
  
  File file = new File(targetPath);
  boolean fileExist = file.exists();
  if (fileExist) {
      long skippedBytes = is.skip(file.length()); 
  }
  
  // opens an output stream to save into file
  OutputStream os = new FileOutputStream(targetPath, fileExist);
  </code></pre>
  
  <p>Its working merely in respect of skipping but actually not working.</p>
  
  <p>Say, file (video) length is 20 sec and in first attempt I downloaded up to 6 sec and rest subsequently. But when I play it just play till 6 sec then after throw the usual Video playback error.      </p>