title: How An use of all images from the parse
body: <p>I need to pull all the image from parse.
  this is the error in the logCat:
  <code>Attempt to invoke interface method 'java.lang.Object java.util.List.get(int)' on a null object reference</code></p>
  
  <p>The error is here:          </p>
  
  <pre><code>String ObjectId =  ParseObjects.get(position).getObjectId();
  </code></pre>
  
  <p>This is my code:                                                 </p>
  
  <pre><code>public void PullImage(final ImageView image,int position){
      progressDialog = ProgressDialog.show(mContext, "", "Downloading Image...", true);
      String ObjectId =  ParseObjects.get(position).getObjectId();
      query.getInBackground(ObjectId, new GetCallback &lt; ParseObject &gt; () {
          public void done (ParseObject object, ParseException e){
              if (object != null) {
                  ParseFile file = (ParseFile) object.get("ImageFile");
                  file.getDataInBackground(new GetDataCallback() {
                      public void done(byte[] data, ParseException e) {
                          if (e == null) {
                              Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
                              // surface.addImage(bitmap);
  
                              // float Xplace  = targetImageforpull.getX();
                              // float Yplace  = targetImageforpull.getY();
  
                              image.setImageBitmap(bitmap);
                              //use this bitmap as you want
                              progressDialog.dismiss();
                          } else {
                              // something went wrong
                          }
                      }
                  });
              } else {
                  Toast.makeText(mContext, "Exception", Toast.LENGTH_SHORT).show();
              }
          }
      });
  }
  </code></pre>
  
  <p>I know that my problem is here:</p>
  
  <pre><code>public void SetParse(){
      query = new ParseQuery&lt;ParseObject&gt;("User");
      //  query.whereEqualTo("Column", bitmap);
       size = 0;
      try {
          size = query.count();
      } catch (ParseException e) {
          e.printStackTrace();
      }
      query.findInBackground(new FindCallback&lt;ParseObject&gt;() {
          public void done(List&lt;ParseObject&gt; objects, ParseException e) {
              if (e == null) {
                  ParseObjects = objects;
                  // The query was successful.
              } else {
                  // Something went wrong.
              }
          }
      });
  }
  </code></pre>
  
  <p>all code:</p>
  
  <pre><code>public class CustomGrid extends BaseAdapter {
      private Context mContext;
      private Bitmap btimaprecieve;
      List&lt;ParseObject&gt; ParseObjects;
  
      ParseQuery&lt;ParseObject&gt; query;
  
      ProgressDialog progressDialog;
  
      int size;
  
      public CustomGrid(Context c) {
          mContext = c;
          SetParse();
      }
  
      //---returns the number of images---
      public int getCount() {
          return size;
      }
  
      //---returns the ID of an item---
      public Object getItem(int position) {
          return imageId[position];
      }
  
      public long getItemId(int position) {
          return position;
      }
  
      //---returns an ImageView view---
      public View getView(int position, View convertView, ViewGroup parent) {
          ImageView imageView;
          if (convertView == null) { // if it's not recycled, initialize some
              // attributes
              imageView = new ImageView(mContext);
              imageView.setLayoutParams(new GridView.LayoutParams(120, 120));
              imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
              imageView.setPadding(25, 25, 25, 25);
          } else {
              imageView = (ImageView) convertView;
          }
          PullImage(imageView,position);
       //   imageView.setImageResource(imageId[position]);
  
          return imageView;
      }
  
      public void SetParse(){
          query = new ParseQuery&lt;ParseObject&gt;("User");
          //  query.whereEqualTo("Column", bitmap);
           size = 0;
          try {
              size = query.count();
          } catch (ParseException e) {
              e.printStackTrace();
          }
          query.findInBackground(new FindCallback&lt;ParseObject&gt;() {
  
              public void done(List&lt;ParseObject&gt; objects, ParseException e) {
                  if (e == null) {
                     // ParseObjects = objects;
                       ParseObjects = new ArrayList&lt;ParseObject&gt;(objects);
                      if(ParseObjects == null){
                          Log.d("ParseObjects is null ", "ParseObjects is null");
                      }
                      if(objects == null){
                          Log.d("objects is null ", "objects is null");
                      }
  
                      // The query was successful.
                  } else {
                      // Something went wrong.
                  }
              }
          });
      }
  
      public void PullImage(final ImageView image,int position){
  
          progressDialog = ProgressDialog.show(mContext, "", "Downloading Image...", true);
          String ObjectId =  ParseObjects.get(position).getObjectId();
          query.getInBackground(ObjectId, new GetCallback &lt; ParseObject &gt; () {
              public void done (ParseObject object, ParseException e){
                  if (object != null) {
  
                      ParseFile file = (ParseFile) object.get("ImageFile");
  
                      file.getDataInBackground(new GetDataCallback() {
  
  
                          public void done(byte[] data, ParseException e) {
                              if (e == null) {
  
                                  Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
                                  // surface.addImage(bitmap);
  
                                  // float Xplace  = targetImageforpull.getX();
                                  // float Yplace  = targetImageforpull.getY();
  
                                  image.setImageBitmap(bitmap);
                                  //use this bitmap as you want
                                  progressDialog.dismiss();
                              } else {
                                  // something went wrong
                              }
                          }
                      });
  
                  } else {
                      Toast.makeText(mContext, "Exception", Toast.LENGTH_SHORT).show();
                  }
              }
          });
      }
  
      private Integer [] imageId = {
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
              R.drawable.like_button,
      };
      public Bitmap add(Bitmap bitmap_recieve) {
          return btimaprecieve;
      }
  }
  </code></pre>