Search code examples
androidparse-platform

How to read a column value in parse.com without accessing an object or a pointer


By using this code, I am not able to get the 'name' unless I use objectId = xJ34wEo.
Suggest a way, if not, at least by using pointer.

//Parse Query Initialization 
final ParseQuery<ParseObject> query = ParseQuery.getQuery("MyUsers");

//To check the row which has "number"="1234"
query.whereEqualTo("number", "1234"); 
query.findInBackground(new FindCallback<ParseObject>() { 
    public void done(List<ParseObject> employees, ParseException e) {
        if (e == null) { 
            try { 
                //xJ34wE0 is objectId 
                query.get("xJ34wEo").get("name") + ""); 
            } catch (ParseException pe) {}
          }
      }
}); 

Solution

  • Are you just trying to get the employee object with that number?

    You have a List<ParseObject>, so use it.

    query.findInBackground(new FindCallback<ParseObject>() { 
        public void done(List<ParseObject> employees, ParseException e) {
            if (e == null && employees.size() > 0) { 
                try { 
                    String name = employees.get(0).get("name");
                    Log.d("PARSE", name);
                } catch (ParseException pe) {}
              }
          }
    });