public void addBookClicked(View view) throws IOException { // EditText et =(EditText)findViewById(R.id.bookName); Book newBook = new Book(); newBook.setBookName(((EditText) findViewById(R.id.editBookName)).getText().toString()); newBook.set_price( Integer.parseInt(((EditText) findViewById(R.id.editBookPrice)).getText().toString())); final Backend backend = BackendFactory.getInstance(this); backend.addBook(newBook); super.onBackPressed(); }