title: Storing images in Arraylist of Images in Android
body: <p>How to store images retrieved from server in Array list of Bitmap ?
  I have tried but the arraylist showing null values.</p>
  
  <p>Following code to get image from server:- </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>ParseQuery&lt;ParseObject&gt; imgquery = new ParseQuery&lt;ParseObject&gt;("ChatRecords");
  imgquery.getInBackground(ChatRecordObjectID, new GetCallback&lt;ParseObject&gt;() 
  {       
   @Override
   public void done(ParseObject object,ParseException e) 
   {
    System.out.println("in 2nd done:"+time2); 
    ParseFile fileObject = (ParseFile) object.get("ImageMessage");
      fileObject.getDataInBackground(new GetDataCallback() 
      {
       @Override
       public void done(byte[] data, ParseException e)
       {
        if (e == null) 
        {
        bmp= BitmapFactory.decodeByteArray(data, 0,data.length);
        imageBitmap.add(bmp);
        }
        else 
        {
       Log.d("test","There was a problem downloading the data.");     }
     }
    });
   }
  });
  
  Following Code to retrieve image in array list :-
  
  for(int i=0;i&lt;imageBitmap.size();i++)
  {
   ImageView imageView = new ImageView(CurrentUserActivity.this);
   imageView.setBackgroundResource(R.drawable.msgrecv);
   imageView.setAdjustViewBounds(true);
   imageView.setMaxHeight(150);
   imageView.setMaxWidth(inScrollViewLeft.getLayoutParams().width);
   imageView.requestLayout();
   imageView.setImageBitmap(imageBitmap.get(i));
   inScrollViewLeft.addView(imageView);
   } </code></pre>
  </div>
  </div>
  </p>
  
  <p>Error is :   </p>
  
  <pre><code>04-28 09:57:08.280: E/AndroidRuntime(2769): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
  04-28 09:57:08.280: E/AndroidRuntime(2769): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
  </code></pre>