I wrote code for SQLite project, and wrote function, that had to use this code. Now I want to attach this function to a button, that appears in another activity. How can I do that? I tried to make onClickListener, or write function in onCreate of main acitivity, but I didn't quite got result.
This is my function:
private void insertInDB(Seifim seifim){
SQLiteDatabase db = helper.getReadableDatabase();
String sql = "INSERT INTO seifim (misparRehev, shemEhida, sugTipul, kamutKilometrim, date, manoa, delek, higui, blamim, zmigim, hashmal, hashlada, abs, mivhan) values('" +
seifim.getMisparRehev() + "','" + seifim.getShemEhida() + "','" + seifim.getSugTipul() + "','" + seifim.getKamutKilometrim() + "','" +
seifim.getDate() + "','" + seifim.getManoa() + "','" + seifim.getDelek() + "','" + seifim.getHigui() + "','" +
seifim.getBlamim() + "','" + seifim.getZmigim() + "','" + seifim.getHashmal() + "','" + seifim.getHashlada() + "','" +
seifim.getAbs() + "','" + seifim.getMivhan();
db.execSQL(sql);
Toast.makeText(getApplicationContext(), "tofes was saved", Toast.LENGTH_LONG).show();
}