简体   繁体   中英

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:

在此处输入图片说明

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:

在此处输入图片说明

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM