1

I want to see if a value is in my firebase database, the user will provide the value thereafter I want to say if the value is present then move to the next activity.

KENdi
  • 7,576
  • 2
  • 16
  • 31
  • check https://stackoverflow.com/questions/38948905/how-can-i-check-if-a-value-exists-already-in-a-firebase-data-class-android – Amir Hedieh Jan 03 '19 at 11:23
  • Also see https://stackoverflow.com/questions/52688217/check-data-if-exist-in-firebase/52689739#52689739 – Frank van Puffelen Jan 03 '19 at 14:19
  • Check also **[this](https://stackoverflow.com/questions/47893328/checking-if-a-particular-value-exists-in-the-firebase-database/47893879)** out. – Alex Mamo Jan 03 '19 at 20:03

1 Answers1

0

Data in firebase is retrieved by adding a asynchronous listener to a database reference. So you have to change the way you are used to retrieve data from other data sources like MySQL...
Thus, define the reference to the part of firebase database where the user is going to insert its data and attach listener to it. In the listener write your code to go to the next activity.
For example:

final FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference ref = database.getReference("server/NodeOfTheUser");    
ref.addValueEventListener(new ValueEventListener() {
  @Override
  public void onDataChange(DataSnapshot dataSnapshot) {
    //your code to go to the next activity
  }

});

For more info: firebase documentation.

Code Pope
  • 5,075
  • 8
  • 26
  • 68