0

Image showing database structure

How can i access the circled email and password using android firebase.so far i have tried using the below code but it does not work.

Mref = new Firebase("https://blah blah/");

        Firebase objRef = Mref.child("Administrators");
        objRef.addChildEventListener(new ChildEventListener() {
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                Map<String, String>map=dataSnapshot.getValue(Map.class);
                String password = map.get("password");
                String email = map.get("email");

                Log.d("email",email);
                Log.d("password",password);

                if(ed1.getText().toString().equals(password)&& ed2.getText().toString().equals(email)){
                    Intent intent=new Intent(Main2Activity.this, MapsActivity.class);
                    startActivity(intent);
                    Log.d("password",password);
                }
                else{
                    Toast.makeText(Main2Activity.this, "Wrong Credentials",Toast.LENGTH_LONG).show();
                }

            }
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • I'm not sure if you can accomplish a find/search this requirement. I suggest using the `email address` as your `key` for each of the driver object instead. I'd be interested to see if there was a way tho.. This might be of some help http://stackoverflow.com/a/34537728/1339516 – Searching Nov 04 '16 at 03:31
  • Frank van Puffelen can you give me a snippet on how i could implement what is written in that link, to my code above – Sbonelo Ngcobo Nov 04 '16 at 09:10
  • So i tried doing it like this but i get an error saying: Failed to bounce to type. for (DataSnapshot snapshot : dataSnapshot.getChildren()) { for (DataSnapshot csnapshot : snapshot.getChildren()) { for (DataSnapshot ccsnapshot : snapshot.getChildren()) { Map map = ccsnapshot.getValue(Map.class); String password = map.get("password"); String email = map.get("email"); – Sbonelo Ngcobo Nov 04 '16 at 13:22

0 Answers0