Example: I have a database that has name, email, but I want to know if this name matches a value that I put in an editText
Help me Thanks so much!!
Asked
Active
Viewed 150 times
-4

adjuremods
- 2,938
- 2
- 12
- 17

Jackson Miguel
- 23
- 3
-
Check the answers for your queries, in stack overflow before posting a question. This can help you save downvotes – Myth Nov 28 '16 at 12:57
-
This might help you: https://gist.github.com/anantn/4323949 – Myth Nov 28 '16 at 13:00
2 Answers
1
First of all initiate the database instance
FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
get the reference of your DB where you want to perform the operation
DatabaseReference dbRef = firebaseDatabase.getReference(NAME_OF_DATABASE);
then use this to get all the user with the name equal to the editText text
Query query = profileDbRef
.orderByChild("name")
.equalTo(edittext.getText().toString());
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot dataSnapshot1 : dataSnapshot.getChildren()) {
Log.d(TAG, dataSnapshot1.getKey() + " " + dataSnapshot1.getValue(Profile.class)
.toString());
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});

Tabish Hussain
- 852
- 5
- 13
-
-
Man, thank you very much I used this code and it worked in my project, however I wanted your help if possible in the following situation: I ordered some data from my database but I wanted it to be in the reverse order, that is, from the largest to the smallest. The biggest result: 100 The lowest result: 0 Would you help me or anybody? – Jackson Miguel Dec 04 '16 at 18:19
-
There is no way to reverse the data by using firebase query you have to do it manually.. or it you are using it for a recyclerView data source it can be done by LinearLayoutManager mManager = new LinearLayoutManager(getContext()); mManager.setReverseLayout(true); – Tabish Hussain Dec 05 '16 at 12:36
-
-
i got solve my problem! Your help was extremely important, thanks so much again! – Jackson Miguel Dec 06 '16 at 12:35
0
I am not very familiar with Firebase, but I found this. I was able to find it pretty easily, so usually just search here once before posting.
You can have a look at this question.
Swift & Firebase | Checking if a user exists with a username
The question there was to do something similar using Swift. Might give you a good start. As for getting the value of the EditText, it is as simple as this.
EditText editText = (EditText) findViewById(R.id.editext1);
String result = editText.getText().toString();

Community
- 1
- 1

Srikkant Srinivasan
- 808
- 9
- 19