0

I am trying to populate an Array from a parse.com query and I am stock in the part of getting the element from query. basically i dont know where to get the current location for exercise_object.get(location) thanks.

    ParseQuery<ParseObject> query = ParseQuery.getQuery("Programs");
    query.whereEqualTo("name", objname);
    query.orderByAscending("name");
    query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> list, ParseException e) {
            if (e == null) {
                //success
                String [] exercice = new String[3];
                exercise_object = list;
                Toast.makeText(Wko_Display.this, "Workouts", Toast.LENGTH_LONG).show();
                ParseObject program_object = exercise_object.get(location);
                exercice [0] = exercise_object.getString("wk0");
                exercice [1] = exercise_object.getString("wk1");
                exercice [2] = exercise_object.getString("wk2");


            } 
2
  • 1
    It's a bit unclear what exactly you're trying to do/need help with. Can you clarify? Commented Jul 8, 2015 at 2:29
  • Trying to populate a string array from a parse object that I am getting from parse.com the problem is that I am getting the whole parse list and I want to go object by object Commented Jul 8, 2015 at 17:52

1 Answer 1

1

If I understand what you're trying to do correctly, then this should work:

@Override
public void done(List<ParseObject> list, ParseException e){
    if (e == null){
        for (ParseObject pObj : list){
            String[] exercise = new String[3];
            // assuming each ParseObject has a pointer to a Program object in the database
            ParseObject programObject = pObj.getParseObject("location");
            // do whatever you want with this programObject

            // then do any further stuff with the current pObj in the list
            exercise[0] = pObj.getString("wk0");
            // ...

        }
    } else{
        Log.e(TAG, e.getMessage()); 
    }
}

This would be wrong if you're expecting only one object to be returned from the query though. Let me know.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.