1
在我的應用程序中,我添加用戶並將他們的詳細信息存儲到我的FireBase數據庫中。我的孩子之一是連接號碼。兩個用戶不應該有相同的連接號碼。所以,當我首先添加一個新的孩子時,它應該檢查我的數據庫中的連接號。如果存在,應顯示敬酒。 這是我添加用戶到我的數據庫的代碼。Android - 在Firebase數據庫中查找現有的孩子
conAddBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
key = mdata.push().getKey();
final String selectArea = addConSpinner.getSelectedItem().toString();
final String due = dueET.getText().toString();
final int mDue = Integer.parseInt(due);
String connectionNum = conNumET.getText().toString();
connectionNum = "Connection Number = " + connectionNum;
final String number = conNumET.getText().toString();
String doorNum = conDoorET.getText().toString();
doorNum = "Door Number = " + doorNum;
String conName = conNameET.getText().toString();
conName = "Name = " + conName;
final String name = conNameET.getText().toString();
String phoneNum = conPhnNumET.getText().toString();
phoneNum = "Phone Number = " + phoneNum;
String aadharNum = conAthreNumET.getText().toString();
aadharNum = "Aadhar Number = " + aadharNum;
String rationNum = conRaCaNumET.getText().toString();
rationNum = "Ration Number = " + rationNum;
ConnectionInformation cInfo = new ConnectionInformation(doc, due, selectArea, finalConnectionNum, finalDoorNum, finalConName, finalPhoneNum, finalAadharNum, finalRationNum,mDue);
mdata.child(selectArea).child(key).setValue(cInfo);
Connections connect = new Connections(number, name, due, doc);
connection.child(selectArea).child(key).setValue(connect);
totalConecinArea = FirebaseDatabase.getInstance().getReference().child("users").child(userID).child("Total No of Connections");
totalConecinArea.child("Total").child(selectArea).child(key).child(number).setValue(mDue);
totalNoConnectionDB.child("Total").child(key).child(number).setValue(mDue);
toast("New Connection " + finalConnectionNum + "," + finalConName + " is added");
Intent i = new Intent(AddConnection.this, AreaGridActivity.class);
startActivity(i);
這是我的數據庫結構。 DataBase Structure
如果您需要任何額外的信息懇請..
這就是我要找的...謝謝.. – Spidey