FlameDra
FlameDra

Reputation: 2087

How to retrieve Array from Parse.com

I have a column in my Parse class which is of type Array, as the image below shows:

enter image description here

It is an ArrayList of Strings that I stored before. I want to retrieve that array into my another activity in my Android application. I'm not quite sure how to go about doing this. Currently, my approach is to make a class that extends the ParseObject class and then make a getter method to retrieve it, as follows:

import com.parse.ParseClassName;
import com.parse.ParseObject;

import java.util.ArrayList;
import java.util.List;


@ParseClassName("Workout")
public class ParseWorkout extends ParseObject{

    public ArrayList<String> getReps() {
        return get("Reps");
    }
}

However, its giving me this error:

enter image description here

What is the proper way to retrieve the stored Array objects?

Upvotes: 2

Views: 1742

Answers (1)

jmateo
jmateo

Reputation: 579

You can use the getList("Reps") method:

@ParseClassName("Workout")
public class ParseWorkout extends ParseObject{

    public List<String> getReps() {
        return getList("Reps");
    }
}

API Reference (moved): http://parseplatform.org/Parse-SDK-Android/api/com/parse/ParseObject.html#getList(java.lang.String)

Upvotes: 3

Related Questions