I am calling this class' method from other class and i always gets false
, How can I update the outer scope data member (status) in
onSuccess()
method, whenever I call this method it always return null, can anyone tell me how can I get the correct result
public class UserAccount {
Firebase firebase;
private UserAccount() {
firebase = new Firebase(firebase_url);
}
public static UserAccount getUserAccountInstance(){
return userAccountInstance;
}
boolean status = false;
public boolean createUserAccount(String username, String password)throws FirebaseException{
if(firebase == null)
firebase = new Firebase(firebase_url);
firebase.createUser(username+"@firebase.com", password, new Firebase.ValueResultHandler<Map<String, Object>>() {
@Override
public void onSuccess(Map<String, Object> result) {
System.out.println("Successfully created user account with uid:" + result.get("uid"));
UserAccount.this.status=true;
}
@Override
public void onError(FirebaseError firebaseError) {
System.out.println("Something went wrong!! \n Account cannot be created.. useraccount");
throw new FirebaseException(firebaseError.getMessage());
}
});
System.out.println("user"+status);// this produces false
return status;
}
I also try static keyword but it didnot work.