我正在尝试创建一个功能,我可以删除"餐厅名称"基于" TextField"中用户的输入单击提交按钮后。
餐厅分为早餐,午餐和晚餐。
我尝试使用remove()
功能,但它会从早餐,名称中删除所有到我的所有数据。
{
"BibleVerse": "Verse1",
"Breakfast": {
"Name": {
"-JyjnX_b6yQCR068oA9i": "firefly",
"-Jyjn_5Wzr1vP5rXi_IG": "congee queen",
"-JyjncESMv5vd2nQh4l6": "steakhouse"
}
},
"Dinner": "Dinner",
"Gathering": "Home",
"Lunch": "Lunch",
"NexcellMember": "Member1",
"User": "Adrian"
}
这是我的Java课程,目前...我不知道如何使用Textfield
中捕获的文本将其设置为从Firebase中删除,我只能删除整个数据集
public class DeleteRestaurant extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.deleterestaurant);
Firebase.setAndroidContext(this);
Button DelRestNow = (Button) findViewById(R.id.delbutton);
DelRestNow.setOnClickListener(Handler);
}
//Specific Button - Delete Restaurant Name
View.OnClickListener Handler = new View.OnClickListener(){
public void onClick(View v){
DelData();
}
};
public void DelData(){
// GET and DELETE(Through Database Restaurant Name
EditText mEdit = (EditText)findViewById(R.id.delText);
String RestName = mEdit.getText().toString();
// Get from Database
Firebase ref = new Firebase("https://myfburl.firebaseio.com");
ref.child("Breakfast/Name").removeValue();
mEdit.setText("");
}
}