I have stored the data on Firebase
as follows:
mlist=dbHandler.getAllContacts(1);
for (int i=0;i<mlist.size();i++) {
reportModel = mlist.get(i);
ref = new Firebase(Config.FIREBASE_URL);
Firebase userRef = ref.child(mUserId);
Map newUserData = new HashMap();
newUserData.put("Sno", reportModel.getSno());
newUserData.put("level", reportModel.getLevel());
newUserData.put("rounds", reportModel.getRounds());
newUserData.put("date", reportModel.getDate());
newUserData.put("time", reportModel.getDatesep());
userRef.push().setValue(newUserData);
mref=userRef.push();
newId=mref.getKey();
}
Now I want to retrieve all the data from the Firebase
database for a specific user. I have written the code as:
for (DataSnapshot ds: dataSnapshot.getChildren()) {
reportModel = new ReportModel();
reportModel.setSno(ds.getValue(ReportModel.class).getSno());
reportModel.setLevel(ds.getValue(ReportModel.class).getLevel());
reportModel.setRounds(ds.getValue(ReportModel.class).getRounds());
reportModel.setDatesep(ds.getValue(ReportModel.class).getDatesep());
mlist.add(reportModel);
}
if(mlist.size()>0){
adapter = new ReportAdapter(mContext, R.layout.adapter_layout,
mlist);
// Binds the Adapter to the ListView
listview.setAdapter(adapter);
}
But the app is crashing with the error :
com.firebase.client.FirebaseException: Failed to bounce to type
I want that if I delete the data from the ListView
then after clicking button the data to be retrieved from Firebase
and stored on ListView
.