I am trying to retrieve data from firebase database in Map format but I am getting a null pointer exception.I have successfully inserted data using map into my firebase data
Change your code at the time of retrieval
Map<String, String> map = (Map) dataSnapshot.getValue();
Instead of
Map map = (Map) dataSnapshot.getValue();
Edit: You can retrieve list of recording using below code
databaseReference1.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
Map<String, String> map = (Map) postSnapshot.getValue();
if (map != null) {
String message = map.get("text");
String userName = map.get("Username");
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});