Get Object

Get a whole Object using a Query:

import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.GetCallback;
import com.parse.ParseException;

public void getObject()
{
  ParseQuery<ParseObject> query = ParseQuery.getQuery("ClassName");
  query.getInBackground("objectId", new GetCallback<ParseObject>() 
  {
    public void done(ParseObject object, ParseException e) 
    {
      if (e == null) 
      {
        // your object will be returned here
      } 
      else 
      {
        // something went wrong, check the exception for more infos
      } 
    }
  });
}

Get the values out of the Object:

import com.parse.ParseObject;

public void getSomeValues(ParseObject object)
{
    int age = object.getInt("age");
    String userName = object.getString("userName");
    boolean isFunny = object.getBoolean("isFunny");
    ParseObject = object.getParseObject("customObject");
}

Special values that have their own accessors:

import com.parse.ParseObject;

public void getSpecialValues(ParseObject object)
{
    String objectId = object.getObjectId();
    Date updatedAt = object.getUpdatedAt();
    Date createdAt = object.getCreatedAt();
    ParseACL acl = object.getACL();
}

Refresh an object that you already have in memory with the latest data:

import com.parse.ParseObject;
import com.parse.GetCallback;
import com.parse.ParseException;

public void refreshObject(ParseObject object)
{
    object.fetchInBackground(new GetCallback<ParseObject>() 
    {
      public void done(ParseObject object, ParseException e) 
      {
        if (e == null) 
        {
          // Success!
        } 
        else 
        {
          // Failure!
        }
      }
    });
}

Last updated