I'm working on retrieving some data from Firebase and i followed some Youtube tutorials that were working fine,
but out of nowhere the retrieving is not working anymore,
the path that i'm setting is correct but i get an empty list even though there is data from where i am retrieving.
private ListView mListView;
private ArrayList<String> mHospitalNames= new ArrayList<>();
private Firebase mRefRoot;
this is the path:
mRefRoot=new Firebase("https://prototype-d2a84.firebaseio.com/Search/"+countryName+"/"+mCity+"/"+bloodType);
this is the code that i am using:
mListView = (ListView) findViewById(R.id.listview);
final ArrayAdapter<String> mArrayAdapter= new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mHospitalNames);
mListView.setAdapter(mArrayAdapter);
mRefRoot.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
String value = dataSnapshot.getValue(String.class);
mHospitalNames.add(value);
mArrayAdapter.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(FirebaseError firebaseError) {
}
});
this is how my database looks like
can someone tell me whats wrong?
Copyright Notice:Content Author:「YaraR」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/43015468/android-studio-retrieving-data-from-firebase-is-not-working