@EgorItChainik

NullPointerException когда все инициализировано как исправить?

Вот проблемный метод
private void userInfodisplay(EditText edit_phone_set, EditText edit_adress_set, EditText edit_name, CircleImageView izmenit_photo) {
        String phone=Prevalent.currentOnlineUser.getPhone();
 UserRef=FirebaseDatabase.getInstance().getReference().child("Users").child(phone);
        UserRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot snapshot) {
                if (snapshot.exists()){
                    if (snapshot.child("image").exists()){
                        String image=snapshot.child("image").getValue().toString();
                        String name=snapshot.child("Username").getValue().toString();
                        String adress=snapshot.child("Adress").getValue().toString();
                        String phonenumber=snapshot.child("Pnomenumder").getValue().toString();
                        Picasso.get().load(image).into(izmenit_photo);
                        edit_phone_set.setText(phonenumber);
                        edit_adress_set.setText(adress);
                        edit_name.setText(name);
                    }
                    if (snapshot.child("address").exists()){
                        String name=snapshot.child("Username").getValue().toString();
                        String adress=snapshot.child("Adress").getValue().toString();
                        String phonenumber=snapshot.child("Pnomenumder").getValue().toString();
                        edit_phone_set.setText(phonenumber);
                        edit_adress_set.setText(adress);
                        edit_name.setText(name);
                    }
                }
            }
            @Override
            public void onCancelled(@NonNull DatabaseError error) {
            }
        });
    }

Проблемная строка
UserRef=FirebaseDatabase.getInstance().getReference().child("Users").child(phone);

Так же почему то проблемное начало этого метода(хотя там только edittext откуда брать данные
userInfodisplay(edit_phone_set ,edit_adress_set, edit_name,izmenit_photo);


Вот prevalent (currentOnlineUser)
public class Prevalent {
    public static Users currentOnlineUser=new Users();
   public static final String UserPhoneKey="UserPhone";
    public static final String UserPasswordKey="UserPassword";
}

Класс Users который в Prevalent
public class Users {
    private  String name,phone,password,image;
    public Users(){
    }
    public Users(String name, String phone, String password,String image) {
        this.name = name;
        this.phone = phone;
        this.password = password;
        this.image=image;
    }
    public String getImage() {
        return image;
    }
    public void setImage(String image) {
        this.image = image;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
}

Ошибка
Caused by: java.lang.NullPointerException: Can't pass null for argument 'pathString' in child()
at com.google.firebase.database.DatabaseReference.child(DatabaseReference.java:96)
at door.one.marketplace.SettingActivity.userInfodisplay(SettingActivity.java:101)
at door.one.marketplace.SettingActivity.onCreate(SettingActivity.java:62)
  • Вопрос задан
  • 73 просмотра
Пригласить эксперта
Ответы на вопрос 1
Geminix
@Geminix
Фуллстек nuxt, .net разработчик
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы