大家好我是Android Studio的新手。我正在尝试构建一个应用程序,但是当我尝试打开某个Activity而其他活动打开时它会继续崩溃,只是第四个就是问题。
public class ForthActivity extends AppCompatActivity {
private EditText email;
private Button Save;
DatabaseReference databaseReference;
@Override
protected void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_forth);
email = (EditText) findViewById(R.id.email);
Save =(Button) findViewById(R.id.btnSave);
databaseReference = FirebaseDatabase.getInstance().getReference().child("Users");
Save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AddData();
}
});
}
public void AddData(){
String Email = email.getText().toString().trim();
SaveData saveData = new SaveData(Email);
databaseReference.push().setValue(saveData);
}
}