I am getting null pointer exception in firebase I knows that there is not any value like that to which database reference I am giving but I wants that when the value is generated then it will be shown automatically... Just wants to get that single value everytime it is created on the firebase but its giving me null pointer exception on the line String val =.....
Please help me ...
final DatabaseReference dtt = database.getReference("/trial/trials/");
dtt.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String val= dataSnapshot.child("myvalue").getValue().toString();
if(val!=null)
{
Log.e("not null------","---------------");
}else
{
Log.e("null------","---------------");
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Please help me.....Please ..