Aposts是我在firebase中的表的名称,我已经声明了所有对象并根据需要对它们进行了类型化,我使用了一个数组来获取值并上传它。
当我调试我得到InputConnectionWrapper问题,并且数据没有上传。
它给我添加了toast消息,但是当我在firebase中检查我的数据库时,它没有上传。
如何解决这个问题?
//to add a new post to database
public class Advpost extends Activity {
Button advbtn;
EditText jobtitle;
EditText jobdescription;
EditText city;
EditText phonenumber;
EditText pay;
EditText emailid;
EditText completiondate;
DatabaseReference posts;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.advpost);
posts = FirebaseDatabase.getInstance().getReference("Aposts");
advbtn = (Button) findViewById(R.id.advbtn);
jobtitle = (EditText) findViewById(R.id.jobtitle);
jobdescription = (EditText) findViewById(R.id.jobdescription);
city = (EditText) findViewById(R.id.city);
phonenumber = (EditText) findViewById(R.id.phonenumber);
pay = (EditText) findViewById(R.id.pay);
emailid = (EditText) findViewById(R.id.emailid);
completiondate = (EditText) findViewById(R.id.completiondate);
advbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addAposts();
}
});
}
private void addAposts() {
String title = jobtitle.getText().toString().trim();
String description = jobdescription.getText().toString().trim();
String cityname = city.getText().toString().trim();
String phno = phonenumber.getText().toString().trim();
String Amt = pay.getText().toString().trim();
String mailid = emailid.getText().toString().trim();
String duedate = completiondate.getText().toString().trim();
if (!TextUtils.isEmpty(title)) {
String id = posts.push().getKey();
Aposts Aposts = new Aposts();
posts.child(id).setValue(Aposts);
Toast.makeText(this, "Added", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Failed", Toast.LENGTH_LONG).show();
}
public class Aposts {
private String title;
private String description;
private String cityname;
private String phno;
private String amt;
private String mailid;
private String duedate;
public Aposts() {
this.title = title;
this.description = description;
this.cityname = cityname;
this.phno = phno;
this.amt = amt;
this.mailid = mailid;
this.duedate = duedate;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getCityname() {
return cityname;
}
public void setCityname(String cityname) {
this.cityname = cityname;
}
public String getPhno() {
return phno;
}
public void setPhno(String phno) {
this.phno = phno;
}
public String getAmt() {
return amt;
}
public void setAmt(String amt) {
this.amt = amt;
}
public String getMailid() {
return mailid;
}
public void setMailid(String mailid) {
this.mailid = mailid;
}
public String getDuedate() {
return duedate;
}
public void setDuedate(String duedate) {
this.duedate = duedate;
}
}