I'm trying to get the the text written by the user in an edittext view and store it in a String value then set this String value in a class that I created that contains two String Objects but when I run the code it gives me an error with a null pointer exception because the "WrittenSubj" and "WrittenDeta" are equal to null, how can i solve this problem?
public class TaskDetails extends AppCompatActivity {
EditText WrittenSubj;
EditText WrittenDeta;
Button SaveBut;
TheTask theTask;
private Database database;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_task_details);
WrittenSubj=(EditText)findViewById(R.id.thesubject);
WrittenDeta=(EditText)findViewById(R.id.theDetails);
SaveBut=(Button)findViewById(R.id.SaveButton);
String subj=WrittenSubj.getText().toString();
String deta=WrittenDeta.getText().toString();
theTask.setSubject(subj);
theTask.setDetails(deta);
}