title: How can I fetch the images in order in parse using ANDROID
body: <p>I have successfully downloaded images from parse but the problem is they are not fetched in order. The images are being downloaded in a background process and I am inserting them in an arrayList to populate the listView. How can I check whether the images are inserted in the same order in the arrayList as they are in the parse backend ? What I have figured out so far is that some images have a smaller size so they are fetched quickly and inserted into the list first but that's not what I want. I want them to be in the same order. What is the possible solution ?</p>
  
  <pre><code>public class FetchClients extends AppCompatActivity {
  public static ArrayList&lt;String&gt; objectID = new ArrayList&lt;String&gt;();
  private ArrayList&lt;String&gt; name              = new ArrayList&lt;String&gt;();
  private ArrayList&lt;String&gt; address           = new ArrayList&lt;String&gt;();
  private ArrayList&lt;Integer&gt; unitNumber       = new ArrayList&lt;Integer&gt;();
  private ArrayList&lt;String&gt; city              = new ArrayList&lt;String&gt;();
  private ArrayList&lt;String&gt; state             = new ArrayList&lt;String&gt;();
  private ArrayList&lt;String&gt; zipCode           = new ArrayList&lt;String&gt;();
  private ArrayList&lt;byte[]&gt; customerImage     = new ArrayList&lt;byte[]&gt;();
  private ListView listView;
  private ContactsAdapter contactsAdapter;
  ImageView testView;
  
  /** Called when the activity is first created. */
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.customers_list);
  
    //  contactsAdapter =
      listView = (ListView) findViewById(R.id.list_view);
  
      loadListView(); // load data in listView
  
  
      listView.setFocusable(true);
      listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id)
          {
  
              Intent intent = new Intent(getApplicationContext(),ClientDetails.class);
              intent.putExtra("name", name.get(position));
              intent.putExtra("address", address.get(position));
              intent.putExtra("unitNumber",unitNumber.get(position));
              intent.putExtra("city", city.get(position));
              intent.putExtra("state", state.get(position));
              intent.putExtra("zipCode", zipCode.get(position));
              intent.putExtra("customerImage", customerImage.get(position));
              startActivity(intent);
  
          }
      });
  }
  
  public void loadListView(){
      ParseQuery&lt;ParseObject&gt; query = ParseQuery.getQuery("Customer");
      query.findInBackground(new FindCallback&lt;ParseObject&gt;() {
          @Override
          public void done(List&lt;ParseObject&gt; customer, com.parse.ParseException e) {
              if (e == null) {
                  for (int i = 0; i &lt; customer.size(); i++) {
                      objectID.add(customer.get(i).getObjectId());
                      name.add(customer.get(i).getString("accountHolder"));
                      address.add(customer.get(i).getString("streetAddress"));
                      unitNumber.add(customer.get(i).getInt("unitNumber"));
                      city.add(customer.get(i).getString("city"));
                      state.add(customer.get(i).getString("state"));
                      zipCode.add(customer.get(i).getString("zipCode"));
  
                      try {
                          ParseFile imageFile = (ParseFile) customer.get(i).get("customerImage");
  
                          imageFile.getDataInBackground(new GetDataCallback() {
                              public void done(byte[] data, ParseException e) {
                                  if (e == null) {
                                      Log.d("test", "We've got data in data.");
                                      customerImage.add(data);
                                      //contactsAdapter.notifyDataSetChanged();
                                      listView.setAdapter(new ContactsAdapter(getApplicationContext(), name
                                              , city, customerImage)); //set custom ListAdapter
  
                                  } else {
                                      Log.d("test", "There was a problem downloading the data.");
                                  }
                              }
                          });
                      }catch(Exception e1){e1.printStackTrace();}
                  }
  
              } else {
                  e.printStackTrace();
                  Toast.makeText(getApplicationContext(), "Unable to get Values", Toast.LENGTH_SHORT).show();
              }
          }
      });
  }
  </code></pre>