Академический Документы
Профессиональный Документы
Культура Документы
it, here
is my code snippet
private void updateValues()
{
if(rAuth !=null && rUser!=null)
{
final String date="15/03/2018";
final DatabaseReference rRef =
FirebaseDatabase.getInstance().getReference()
.child("Users")
.child("Transactions");
rRef.child("Expense").addValueEventListener(new ValueEventListener()
{
@Override
public void onDataChange(DataSnapshot rSnap)
{
for(DataSnapshot d: rSnap.getChildren())
{
rRef.child(d.getKey())
.child("Date")
.addListenerForSingleValueEvent(new ValueEventListener()
{
@Override
public void onDataChange(DataSnapshot dataSnapshot)
{
if(date.equals(dataSnapshot.getValue().toString()))
{
recordItems.add(new recordItems(iconGetter(d.child("Type").getValue().toString()),
d.child("Description").getValue().toString(),
d.child("Type").getValue().toString(),
d.child("Value").getValue().toString(),
d.child("Date").getValue().toString()));
}
}
@Override
public void onCancelled(DatabaseError databaseError)
{
}
});
}
initRecycler();
}
@Override
public void onCancelled(DatabaseError databaseError)
{
}
});
2 Answers
First of all you should fix those code line and add the User-id:
String Date,Description,Type,Value;
public ExpenseModel(){
Date = date;
Description = description;
Type = type;
Value = value;
}
return Date;
}
Date = date;
}
return Description;
}
Description = description;
}
rRef.child("Expense").addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
yourAdapter.add(expenseModel);
yourAdapter.notifyDataSetChanged();
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
@Override
public void onCancelled(DatabaseError databaseError) {
}
});