I have saved date as the key. Now I want to retrieve the dates to the list view. I am aware of how to retrieve the child value to the listview but not sure how to do the same for key values. Below is the code i am using:
databaseReference = FirebaseDatabase.getInstance().getReference().child(savedCollname).
child("Students").child(userId).child("Lectures").child(post_key);
FirebaseListOptions<String> options = new FirebaseListOptions.Builder<String>()
.setLayout(R.layout.subject_list_heading)
.setQuery(databaseReference, String.class)
.build();
adapter = new FirebaseListAdapter<String>(options) {
@Override
protected void populateView(View v, String model, int position) {
TextView subject_name = v.findViewById(R.id.tv_sub_heading);
subject_name.setText(model);
}
};
list_of_date.setAdapter(adapter);
My app crashes with the error: Failed to convert value of type java.util.Hashmap to String
JSON object of database:
{
"-LHSdSCzD_tZhzqvSOw_" : {
"17-7-2018" : {
"Absent" : "0",
"Present" : "1",
"Total_Lectures" : "1"
},
"18-7-2018" : {
"Absent" : "0",
"Present" : "1",
"Total_Lectures" : "1"
}
}
I want to retrieve the dates ie the node to the listview. If there is any other way please do mention. Any help is appreciated.