I'm trying to get the value relatedGuild from ParseObject relationShipObject that has been sent to another method.
My code:
private void getRelation(){
Log.i("Status:", "Retrieving current user...");
//Retrieve the current logged in user
ParseUser currentUser = ParseUser.getCurrentUser();
Log.i("Status:", "Retrieving relationship...");
//Retrieve the relationship object for currentUser
ParseQuery<ParseObject> relationQuery = ParseQuery.getQuery("relation");
query.whereEqualTo("relatedUser", currentUser);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> relationShip, ParseException e) {
if (e == null) {
for (ParseObject relationShipObject : relationShip) {
// This does not require a network access.
relationshipObject.get("relatedGuild");
getGuild(relationShipObject);
}
} else {
Log.d("relation", "Error: " + e.getMessage());
}
}
});
}
private void getGuild(ParseObject relationShipObject){
Log.d("relation", "relationShipObject:" + relationShipObject.getString("relatedGuild"));
}
When i call Log.d in method getGuild i get a value equal to null. Am I trying to retrieve the value from row relatedGuild the wrong way? If yes, do you have any solution to the problem?
Update:
When i change from getString to get("relatedGuild").toString(), i get a value that looks like this: com.parse.ParseObject@21u702b7. That means relationShipObjectcontains some kind of value i don't know how to retrieve.
relatedGuildis a ParseObject, which indicates that it is a pointer. So you can get the object from that pointer field by callingrelationShipObject.getParseObject("relatedGuild"). Then what you want to do with it is up to you.