【问题标题】:Query Data from Parse.com从 Parse.com 查询数据
【发布时间】:2015-09-28 16:37:04
【问题描述】:

我是初学者,所以我不了解 parse.com 中的很多内容。 我在 Parse.com 中有一个类 Photo extends ParseObject 和一个表 Object photo。 当我从照片中查询数据时,我遇到了问题。 这是我的问题:

java.lang.IllegalArgumentException: value may not be null.

这是我的照片课:

@ParseClassName("photo")
public class Photo extends ParseObject {
public Photo() {
}
public void setPhoto(ParseFile photo){
    put("imageFile", photo);      ///value may not be null.
}
public ParseFile getPhoto() {
    return getParseFile("imageFile");
}
public void setName(String string){
    put("ImageName",string);
}
public String getName(){
    return getString("ImageName");
}
}

这是我的代码:

final ArrayList<Photo> photos = new ArrayList<>();
            try {
                ParseQuery<ParseObject> query1 = new ParseQuery<>("photo");
                query1.whereMatches("trade_id",idTrade);
                list = query.find();
                for (ParseObject mPhoto : list) {
                    Photo newPhoto = new Photo();
                    newPhoto.setPhoto((ParseFile) mPhoto.get("imageFile"));
                    photos.add(newPhoto);
                }
            } catch (com.parse.ParseException e) {
                Log.e("Error", e.getMessage());
                e.printStackTrace();
            }

我在 Parse 中的表有 2 列:imageFile(File) & trade_id(String) 告诉我如何解决?请!

【问题讨论】:

  • 在哪一行抛出异常?变量query1idTradelistmPhotonewPhotophotos 的值都有效吗?
  • 他们没问题,你看到我代码中的注释 ///value 可能不为空。
  • 您能否粘贴一张您的表格在解析时的样子的屏幕截图。您的错误陈述并没有说明什么。
  • 我无法上传照片。我的表有 2 列:imageFile(文件)和 trade_id(字符串):(
  • 我不确定“值可能不为空”的评论是什么意思

标签: android parse-platform


【解决方案1】:

你不应该这样做吗

mPhoto.getParseFile("imageFile")

而不是

mPhoto.get("imageFile")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-30
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    • 1970-01-01
    相关资源
    最近更新 更多