how to pass arguments in constructor : here I attached my code:


I have a class called Contacts():

public class Contacts {

    int _id;
    String _name;
    String _mobile;
    String _home;
    String _office;
    String _email;
    String _companyName;
    String _jobRole;
    String _address;


    public Contacts( String name, String mobile, String home, String office, String address, String email,String companyName, String jobRole ) {

         this._name = name;
        this._mobile = mobile;
        this._home = home;
        this._office = office;
        this._address = address;
        this._email = email;
        this._companyName = companyName;
        this._jobRole = jobRole;

    }
    public Contacts(int id, String name, String mobile, String home, String office,String address,String email,String companyName, String jobRole ) {

        this._id = id;
         this._name = name;
        this._mobile = mobile;
        this._home = home;
        this._office = office;
        this._address = address;
        this._email = email;
        this._companyName = companyName;
        this._jobRole = jobRole;

    }

    public Contacts() {

    }


    public String getCompanyName() {
        return _companyName;
    }

    public void setCompanyName(String companyName) {
        this._companyName = companyName;
    }

    public String getEmail() {
        return _email;
    }

    public void setEmail(String email) {
        this._email = email;
    }

    public String getHome() {
        return _home;
    }

    public void setHome(String home) {
        this._home = home;
    }

    public int getId() {
        return _id;
    }

    public void setId(int id) {
        this._id = id;
    }

    public String getJobRole() {
        return _jobRole;
    }

    public void setJobRole(String jobRole) {
        this._jobRole = jobRole;
    }

    public String getMobile() {
        return _mobile;
    }

    public void setMobile(String mobile) {
        this._mobile = mobile;
    }

    public String getName() {
        return _name;
    }

    public void setName(String name) {
        this._name = name;
    }

    public String getOffice() {
        return _office;
    }

    public void setOffice(String office) {
        this._office = office;
    }

    public String getAddress() {

        return _address;
    }

    public void setAddress(String address) {
        this._address = address;
    }
}


and i have method called updateContact()  and addContact() which are present inside a class called Dbhandler() that extends SQLiteOpenHelper() 

  public boolean updateContact(Contacts contacts) {

        SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(KEY_NAME,contacts.getName());
        contentValues.put(KEY_MOBILE,contacts.getMobile());
        contentValues.put(KEY_HOME,contacts.getHome());
        contentValues.put(KEY_OFFICE,contacts.getOffice());
        contentValues.put(KEY_ADDRESS,contacts.getAddress());
        contentValues.put(KEY_EMAIL,contacts.getEmail());
        contentValues.put(KEY_COMPANYNAME,contacts.getCompanyName());
        contentValues.put(KEY_JOBROLE,contacts.getJobRole());
        sqLiteDatabase.update(TABLE_CONTACTS,contentValues,KEY_ID + "= ?",new String[] {String.valueOf(contacts.getId())});
        return  true;


    }

 public void addContact(Contacts contacts) {

        SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(KEY_NAME,contacts.getName());
        contentValues.put(KEY_MOBILE,contacts.getMobile());
        contentValues.put(KEY_HOME,contacts.getHome());
        contentValues.put(KEY_OFFICE,contacts.getOffice());
        contentValues.put(KEY_ADDRESS,contacts.getAddress());
        contentValues.put(KEY_EMAIL,contacts.getEmail());
        contentValues.put(KEY_COMPANYNAME,contacts.getCompanyName());
        contentValues.put(KEY_JOBROLE,contacts.getJobRole());


        sqLiteDatabase.insert(TABLE_CONTACTS,null,contentValues);
        sqLiteDatabase.close();
    }


and I have a button which is represented as button1 in display.xml file.

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="run"
            android:text="@string/save"
            android:layout_below="@+id/editAddress"
            android:layout_centerHorizontal="true" />


onClick(), I implemented run() method in DisplayContacts() class.

public void run(View view) {

        Bundle bundle = getIntent().getExtras();
        if(bundle != null) {

            int value =bundle.getInt("id");
            if(value > 0) {
                if(dbHandler.updateContact(id_update,name.getText().toString(),mobile.getText().toString(),home.getText().toString(),office.getText().toString(),companyName.getText().toString(),jobRole.getText().toString(),email.getText().toString(),address.getText().toString())) {

                    Toast.makeText(getApplicationContext(), "Updated", Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent(getApplicationContext(),Example4.class);
                    startActivity(intent);
                } else{
                    Toast.makeText(getApplicationContext(), "not Updated", Toast.LENGTH_SHORT).show();
                }
            } else{
                if(dbHandler.addContact(name.getText().toString(), mobile.getText().toString(),home.getText().toString(),office.getText().toString(), companyName.getText().toString(),jobRole.getText().toString(),email.getText().toString(),address.getText().toString())){
                    Toast.makeText(getApplicationContext(), "done", Toast.LENGTH_SHORT).show();
                } else{
                    Toast.makeText(getApplicationContext(), "not done", Toast.LENGTH_SHORT).show();
                }
                Intent intent = new Intent(getApplicationContext(),Example4.class);
                startActivity(intent);
            }
        }


At this point I am getting error.ie.,
if(dbHandler.updateContact(id_update,name.getText().toString(),mobile.getText().toString(),home.getText().toString(),office.getText().toString(),companyName.getText().toString(),jobRole.getText().toString(),email.getText().toString(),address.getText().toString())) {}

and

  if(dbHandler.addContact(name.getText().toString(), mobile.getText().toString(),home.getText().toString(),office.getText().toString(), companyName.getText().toString(),jobRole.getText().toString(),email.getText().toString(),address.getText().toString())){}

Why this?
and 
How to fix this?
can you please help me with updated code.
thank you...

