title: How to know the size of a file from url befor downloading it?
body: <p>Hi I am new for android and in my app I have to find the file size before downloading it.</p>
  
  <p>For this I wrote the code below, but it's giving me content length 2588 but the actual size of my file is 745 MB. </p>
  
  <p>Please help me. How can I find the exact file size in MB's?</p>
  
  <h2>code:-</h2>
  
  <pre><code>URL url = new URL("mu url");
  URLConnection urlConnection = url.openConnection();
  urlConnection.connect();
  int file_size = urlConnection.getContentLength();
  </code></pre>