I have two java class files namely a. listmasteritems b. Mydbhandler.
In an activity I use an edittext and a button. On button click in the device, I intend to send the text to the database. I get an error on button click (in device) stating
'Unfortunately,tommy has stopped working' when I include the line
'dbHandler.addNewAccountName(name);'.
Hereunder is my code:
public void onBtnIncludeClick( View v)
{
listmasteritems name=new listmasteritems(editText.getText().toString());
dbHandler.addNewAccountName(name);
}
In Mydbhandler:
//add new row to the database
public void addNewAccountName(listmasteritems name)
{
ContentValues values= new ContentValues();
values.put(COLUMN_NAME,name.get_accountname());
SQLiteDatabase db=getWritableDatabase();
db.insert(TABLE_ACCOUNTHEADS,null,values);
db.close();
}