I am trying to retrieve data from firebase. But, i couldn't find a method to retrieve data from firebase database. Now i am out of ideas please help me.
private void attachDataBaseReadListener() {
if (mChildEventListener == null) {
mChildEventListener = new ChildMsgEventListener();
mMsgDatabaseReference.AddChildEventListener(mChildEventListener);
}
}
private class ChildMsgEventListener : Java.Lang.Object, IChildEventListener
{
public void OnCancelled(DatabaseError error)
{
throw new NotImplementedException();
}
// when added the item , you can retrieve the data from the database
public void OnChildAdded(DataSnapshot snapshot, string previousChildName)
{
var obj = snapshot.Children;
foreach (DataSnapshot s in obj.ToEnumerable())
{
var model = FriendlyMessage.MapToMsgModel(snapshot);
if (model != null && !IsExisting(model)) {
Log.Debug(TAG,"current model = " + model.ToString());
msgList.Add(model);
}
}
mMessageAdapter.NotifyDataSetChanged();
}
public void OnChildChanged(DataSnapshot snapshot, string previousChildName)
{
throw new NotImplementedException();
}
public void OnChildMoved(DataSnapshot snapshot, string previousChildName)
{
throw new NotImplementedException();
}
public void OnChildRemoved(DataSnapshot snapshot)
{
throw new NotImplementedException();
}
}
Answers
I have developed a chat app by FireBase ,and it works well.
The Object I used to comunicated with FireBase Server is as follows:
The first three fields are stored in Database as follows:

The main code to communicate with FireBase database is as follows :
1. send message to FireBase database
2. method
attachDataBaseReadListener
:Have you got your solution at last?
Can you provide the full code
Including the class name