I want to show user Profile image for each post. I wrote a code for this but i am getting an error.
//Here is error---
FATAL EXCEPTION: main
Process: com.example.serhat.blog, PID: 5614 java.lang.NullPointerException: Can't pass null for argument 'pathString' in child()
at com.google.firebase.database.DatabaseReference.child(Unknown Source)
at com.example.serhat.blog.MainActivity$2.populateViewHolder(MainActivity.java:95)
at com.example.serhat.blog.MainActivity$2.populateViewHolder(MainActivity.java:80)
//Here is my code
//Profile image//
mDatabaseUsers.child(model.getUserid()).child("image").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String image = dataSnapshot.getValue(String.class);
viewHolder.setProfileImage(MainActivity.this,image);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
//Here is blog class
private String title,description,image,uid,username,senddate;
public Blog()
{
}
public Blog(String title, String description, String image, String uid, String username,String senddate,String profileimageUri) {
this.title = title;
this.description = description;
this.image = image;
this.uid = uid;
this.username = username;
this.senddate=senddate;
}
public String getUserid() {
return uid;
}
public void setUserid(String uid) {
this.uid = uid;
}
Solved. Thanks for your answers. The problem is my database stracture in firebase i changed 'uid' to 'userid' and problem solved.
The problem is method names and the domain name in the database are not the same.