我这个问题已经工作了近一个月,但找不到答案。我有一个名为“shulMinyans”的ParseRelation,我保存在一个名为“Shul”的ParseObject中。我在网上查看了ParseRelation正确保存并且保存得很好。当我尝试检索对象时,关系显示ParseRelation中没有已知对象。除了ParseRelation之外,ParseObject的所有其他数据下载都很好。这是我的代码:
ParseUser userToSync = ParseUser.getCurrentUser();
Shul shulForID = (Shul) userToSync.get("shul");
String shulID = shulForID.getObjectId();
ParseQuery<Shul> shulQuery = ParseQuery.getQuery("Shul");
shulQuery.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ONLY);
ArrayList<Minyan> oneArray = null;
try {
Shul shulToLoad = shulQuery.get(shulID);
shulToLoad.loadShul(userToSync);
ParseRelation shulMinyans = shulToLoad.getRelation("shulMinyans");
ParseQuery query = shulMinyans.getQuery();
try {
oneArray = (ArrayList<Minyan>) query.find();
} catch (ParseException e) {
e.printStackTrace();
}
} catch (ParseException e) {
e.printStackTrace();
}
如何让ParseRelation检索我存储的数据?
答案 0 :(得分:0)
你可以尝试一下吗?
ParseObject parseShul = ParseObject.createWithoutData("Shul", shulId);
ParseRelation<ParseObject> relation = parseShul.getRelation("shulMinyans");
ParseQuery<ParseObject> query = relation.getQuery();
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
// Do something here
}
});