here is the code of the onclick of button , what i want to do is on click of his button app must fetch the email from the firebase database if successful it must show up in edit text that email found else show in Edit-text that email not found , here i am able to fetch the email and show that email found on Edit-text but not able to show the email not found (else part of the code ) instead i get this in console
W/PersistentConnection: pc_0 - Using an unspecified index. Consider adding '".indexOn": "email"' at /users/users to your security and Firebase rules for better performance
conbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Firebase ref = new Firebase("https://(refrence of firebse database)");
final String searchEmail = emailcon.getText().toString().trim();
final Query query = ref.orderByChild("email").equalTo(searchEmail);
query.addValueEventListener(new ValueEventListener()
{
@Override
public void onDataChange(DataSnapshot dataSnapshot)
{
for (DataSnapshot child : dataSnapshot.getChildren())
{
final String fetchEmail;
Map<?, ?> value = (Map<?, ?>) child.getValue();
Log.d("main2activity ","User data : "+ value);
fetchEmail = (String) value.get("email");
Log.d("main2activity ","User email : "+ fetchEmail);
if (searchEmail.equals(fetchEmail))
{
emailcon.setText("email found hurray "+query.getRef());
}
else
{
emailcon.setText("still no email found!!");
}
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
});
Aucun commentaire:
Enregistrer un commentaire