title: Download Streamed gif file and store in byte array
body: <p>I am building an android app where I need to down load a gif image from a URL and store in a byte array. Been using bitmap factory classes but it keeps returning null.  I am storing the byte array to sqlite  then retrieving and displaying.</p>
  
  <pre><code>    urlConnection = (HttpURLConnection) url.openConnection();
  
          InputStream is = urlConnection.getInputStream();
  
  
          BufferedInputStream bis = new BufferedInputStream(is);
          ByteArrayOutputStream buffer = new ByteArrayOutputStream();
          //We create an array of bytes
          byte[] data = new byte[4094];
          int current = 0;
  
          while((current = bis.read(data,0,data.length)) != -1){
              buffer.write(data,0,current);
          }
  </code></pre>
  
  <p>I have even tried to convert using the Bitmap.Factory, but returns nulls.</p>