How I can retrieve uid2
"myChat" : {
"LVaLUQ9eN8PmkazanpXzL7QdP573" : {
"f4cTqaXf81R5dTI5AV5pMWLIjoB2" : {
"Massige" : {
"-KzyFATWHPh81MqAMiI7" : {
"author" : "mohammed",
"authorL" : "mohammed",
"text" : "hi",
"uid" : "LVaLUQ9eN8PmkazanpXzL7QdP573",
"urlPhoto" : "https://firebasestorage.googleapis.com/v0/b/-acf07.appspot.com/o/LVaLUQ9eN8PmkazanpXzL7QdP573%2FmyImgebackgroun%2Fbaground?alt=media&token=744484a1-339b-4bc4-889a-019fb85854fa"
},
},
"id" : {
"uid2" : "mohammed"
}
}
},
"f4cTqaXf81R5dTI5AV5pMWLIjoB2" : {
"LVaLUQ9eN8PmkazanpXzL7QdP573" : {
"Massige" : {
"-KzyFATbNXQLpQhIofau" : {
"author" : "mohammed",
"authorL" : "mohammed",
"text" : "hi",
"uid" : "LVaLUQ9eN8PmkazanpXzL7QdP573",
"urlPhoto" : "https://firebasestorage.googleapis.com/v0/b/-acf07.appspot.com/o/LVaLUQ9eN8PmkazanpXzL7QdP573%2FmyImgebackgroun%2Fbaground?alt=media&token=744484a1-339b-4bc4-889a-019fb85854fa"
},
},
"id" : {
"uid2" : "mohammed"
}
}
}
},
This code which i was try to retrieve but not worked.
final TextView text=(TextView)findViewById(R.id.textView26);
reference = FirebaseDatabase.getInstance().getReference("myChat");
mAuth = FirebaseAuth.getInstance();
String currentUser = mAuth.getCurrentUser().getUid();
reference.child(currentUser).child("id").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
final String name = dataSnapshot.child("uid2").getValue().toString();
text.setText(name);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
error log
E/AndroidRuntime: FATAL EXCEPTION: main, PID: 9410 java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference at at com.google.android.gms.internal.zzbpx.zza(Unknown Source) at com.google.android.gms.internal.zzbqx.zzZT(Unknown Source) at com.google.android.gms.internal.zzbra$1.run(Unknown Source) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)