I'm using Parse.com, and to get my wanted information, I use it's Queries.
So I use that one:
ParseUser PhotoeUser;
ParseQuery<Photo> UserQuery = ParseQuery.getQuery(Photo.class);
UserQuery.whereEqualTo("objectId", PhotoID);
UserQuery.getFirstInBackground(new GetCallback<Photo>() {
@Override
public void done(Photo pPhoto, ParseException error) {
PhotoUser = pPhoto.getUser();
}
});
So what I want is simply use the PhotoUser
outside of that query. But When I write:
Log.i("Profile", "PhotoUser = " + PhotoUser.get("objectId"));
PhotoUser.get("objectId")
is null
.
Another example is this one:
public ParseUser getUser(){
ParseQuery<Photo> UserQuery = ParseQuery.getQuery(Photo.class);
UserQuery.whereEqualTo("objectId", PhotoID);
UserQuery.getFirstInBackground(new GetCallback<Photo>() {
@Override
public void done(Photo pPhoto, ParseException error) {
PhotoUser = pPhoto.getUser();
}
});
return PhotoUser;
}
Here, when I want to return the PhotoUser
, it is null
.
Please help me. If you need more information, just ask for it.
Just take ParseUser outside the block:
PhotoUser pUser;
ParseQuery<Photo> UserQuery = ParseQuery.getQuery(Photo.class);
UserQuery.whereEqualTo("objectId", PhotoID);
UserQuery.getFirstInBackground(new GetCallback<Photo>() {
@Override
public void done(Photo pPhoto, ParseException error) {
pUser = pPhoto.getUser();
}
});
Don't forget to give variables names. I don't know how do You want to get PhotoUser
when You query for Photo
.