Skip to content Skip to sidebar Skip to footer

Parse.com Get Value With Query

I've been looking for an example on how to use Parse.com queries. It's been really vague. I think it should start with: ParseQuery query=ParseQuery.getQuery(

Solution 1:

Parse's Android Guide has a basic query example here which will return the first object which matches your constraints:

ParseQuery<ParseObject> query = ParseQuery.getQuery("YourClassName");
query.whereEqualTo("ID", "someID");
query.getFirstInBackground(newGetCallback<ParseObject>() {
  publicvoiddone(ParseObject object, ParseException e) {
    if (object == null) {
      Log.d("score", "The getFirst request failed.");
    } else {
      Log.d("score", "Retrieved the object.");
    }
  }
});

Solution 2:

I would not recommend using getFirstInBackground for getting a query, it is much better to use findInBackGround and then filtering the value you are looking for.

Solution 3:

To find the list of user whose username starts with abc,You can use the condition

query.whereStartsWith("username", "abc");

So the entire query looks as

ParseQuery<ParseObject> query = ParseQuery.getQuery("YourClassName");
query.whereStartsWith("username", "abc");
query.findInBackground(newFindCallback<ParseObject>() {
  publicvoiddone(List<ParseObject> object, ParseException e) {
    if (object == null) {
      Log.d("score", "The getFirst request failed.");
    } else {
      Log.d("score", "Retrieved the object.");
    }
  }
});

Post a Comment for "Parse.com Get Value With Query"