我正在嘗試使用Firebase數據庫登錄,其中我已經存儲了一些數據。使用Android Studio查詢Firebase數據庫
,所以我需要發佈一些類型的查詢搜索其匹配所輸入的憑證輸入特定節點,並查看確認其參考的關鍵。 這是我的代碼,它似乎並不成功,因爲它總是用於例外情況,併發出錯誤敬酒。 我不止是有義務解決我的問題。
public class LogInActivity extends AppCompatActivity {
DatabaseReference Rootref = FirebaseDatabase.getInstance().getReference();
DatabaseReference mwritefarmref = Rootref.child("WRITE FARM");
DatabaseReference muserprofilestab = mwritefarmref.child("USER PROFILES");
EditText mobinputtext;
EditText passwordinputtext;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log_in);
mobinputtext = (EditText) findViewById(R.id.mobinputtext);
passwordinputtext = (EditText) findViewById(R.id.passinputtext);
tv = (TextView) findViewById(R.id.textView);
Button submitbutton = (Button) findViewById(R.id.submitbutton);
submitbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
DatabaseReference muserid = (DatabaseReference) muserprofilestab.orderByChild("Mobile number").equalTo(mobinputtext.getText().toString());
tv.setText(muserid.getKey());
}catch (Exception e){
Toast.makeText(LogInActivity.this, "ERROR!!", Toast.LENGTH_SHORT).show();
}
}
});
}
}
我將首先更改數據庫結構。另外,請避免在'keys'中有空格。使用camelCaseLetters。 –
哦!感謝您的建議! :D –
但是現在有沒有辦法在這個DataBase本身上執行所需要的?! –