如何在firebase android中获取特定值

时间:2017-07-14 19:59:42

标签: android firebase firebase-realtime-database

我在firebase中的数据如下:

Check Firebase Data Image

以Json格式显示的结构:

{
  "Admin" : {
    "-Kp0mScwQLk0CHarwIUj" : {
      "Account Type" : "Admin",
      "Email Address" : "admin01@dsu.edu.pk",
      "Name" : "Ali Bukhari"
    },
    "-Kp0nC9pVefh65_SFcpu" : {
      "Account Type" : "Admin",
      "Email Address" : "a@test.com",
      "Name" : "Admin"
    }
  },
  "Company" : {
    "-Kp0eMor6BovZHTUZSKR" : {
      "Account Type" : "Company",
      "Company Name" : "SI Labs",
      "Email Address" : "silabs@dsu.edu.pk",
      "Industry" : "IT",
      "No of Employees" : "25",
      "Year Founded" : "2014"
    },
    "-Kp0fgQs7iE6AbIho7Eo" : {
      "Account Type" : "Company",
      "Company Name" : "Panacloud",
      "Email Address" : "panacloud@gmail.com",
      "Industry" : "IT",
      "No of Employees" : "100",
      "Year Founded" : "2014"
    }
 }
}

我正在通过EditText从用户那里获取电子邮件地址输入。 我想查找用户提供的电子邮件地址的“帐户类型”。 例如:用户输入“silabs@dsu.edu.pk”,所以我想在这个例子中为它的“账户类型”,即公司干杯。

private EditText mEmailAuthen = (EditText).findViewById(R.id.emailAuthen);
String mEmail = mEmailAuthen.getText().toString();

DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
Query query = mDatabase.orderByChild("Email Address").equalTo(mEmail);

我试过这个,但不知道该怎么做。

0 个答案:

没有答案