Reputation: 316
I wanna know why my whole data is not getting stored in Firebase Database? Here is a Screenshot of of my data.
Here is The Code
private void sendMessage() {
DatabaseReference db = FirebaseDatabase.getInstance().getReference().child("Message");
String message = editTextMessage.getText().toString();
if (message.isEmpty()) {
Toast.makeText(this, "Text cannot be empty", Toast.LENGTH_LONG).show();
} else {
Messages chat = new Messages(user.getUid(), friendId, message, false);
String chatID = db.push().getKey();
db.child(chatID).setValue(chat);
editTextMessage.setText("");
}
}
My Model Class
public class Messages {
String senderId, receiverID, message;
boolean isSeen;
public Messages(){}
public Messages(String senderId, String receiverID, String message, boolean isSeen) {
this.senderId = senderId;
this.receiverID = receiverID;
this.message = message;
this.isSeen = isSeen;
}
public boolean isSeen() {
return isSeen;
}
public void setSeen(boolean seen) {
isSeen = seen;
}
public String getSenderId() {
return senderId;
}
public String getReceiverID() {
return receiverID;
}
public String getMessage() {
return message;
}
As you can see I am storing 4 values in the chat
object but it is only storing three.
Any Idea or Suggestion why this might be...
Upvotes: 0
Views: 37
Reputation: 317372
It's almost certainly the case that friendId
is null. Realtime Database won't store anything for null values. We can't see where you are giving friendId
a value, so you'll have to debug why this is.
Upvotes: 1