I am new to android and just learned to create a users profile like facebook or instagram, currently I have registered four users with email/password and in database am storing there email, name, phone. In another activity am trying to fetch only the names of the registered users like "People you may know" in facebook, but it is displaying nothing.
private void showData(DataSnapshot dataSnapshot) {
for (DataSnapshot ds: dataSnapshot.getChildren()) {
UserInformation userInformation = new UserInformation();
userInformation.setName(ds.child("users").child("name").getValue(UserInformation.class).getName());
ArrayList<String> array = new ArrayList<>();
array.add(userInformation.getName());
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, array);
mListView.setAdapter(adapter);
}
is this correct way of fetching it because am getting NullPointerException, UserInformation is model class containing getters and setters.
fire-18b42
users
KWE45gijkfJDK6782IBkjas(UID)
email: "@example.com"
name: "Example"
phone_num: 10000000
This is how I have stored the data to database once the user is registered, now like this I have four users and I want to extract every ones name in seperate listView.