Android app crashes when trying to add data to sqlite database : <p>So I've created an sqlite database table which I checked was created. However the app crashes every time I try to add data. I have another similar table that is implemented the same way and works just fine so I'm guessing the problem is somewhere in the button?</p>

<p>My Database class:</p>

<pre><code>package com.example.drivopro.drivopro;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;    
import java.util.ArrayList;
import java.util.List;


public class DatabaseHelper extends SQLiteOpenHelper {
    public static final String DATABASE_NAME = "Company.db";

    //My company table
    public static final String TABLE_ME = "TABLE_ME";
    public static final String MY_ID = "ID";
    public static final String MY_NAME = "NAME";
    public static final String MY_ADDRESS = "ADDRESS";
    public static final String MY_ZIP = "ZIPCODE";
    public static final String MY_CITY = "CITY";
    public static final String MY_PHONE = "PHONE";

    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {         
        db.execSQL("CREATE TABLE " + TABLE_ME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT,NAME TEXT,ADDRESS TEXT,ZIPCODE TEXT,CITY TEXT,PHONE TEXT)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_ME);
        onCreate(db);
    }

    public boolean insertMyCompany(String name, String address, String zipcode, String city, String phone) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(MY_NAME, name);
        contentValues.put(MY_ADDRESS, address);
        contentValues.put(MY_ZIP, zipcode);
        contentValues.put(MY_CITY, city);
        contentValues.put(MY_PHONE, phone);
        long result = db.insert(TABLE_ME, null, contentValues);
        if (result == -1)
            return false;
        else
            return true;
    }        
}
</code></pre>

<p>Activity I'm working with:</p>

<pre><code>package com.example.drivopro.drivopro;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class ModifyCompanyInfo extends AppCompatActivity {

    DatabaseHelper myDb;
    Button btnsave;
    EditText changeName, changeAddress, changeZip, changeCity, changePhone;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_modify_company_info);

        btnsave = (Button)findViewById(R.id.saveComp);
        changeName = (EditText)findViewById(R.id.myName);
        changeAddress = (EditText)findViewById(R.id.myAddress);
        changeZip = (EditText)findViewById(R.id.myZip);
        changeCity = (EditText)findViewById(R.id.myCity);
        changePhone = (EditText)findViewById(R.id.myPhone);

        addData();
    }

    public void addData(){
        btnsave.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        boolean isInserted = myDb.insertMyCompany(changeName.getText().toString(),
                                changeAddress.getText().toString(),
                                changeZip.getText().toString(),
                                changeCity.getText().toString(),
                                changePhone.getText().toString());
                        if(isInserted)
                            Toast.makeText(ModifyCompanyInfo.this, "Tietoja muutettu", Toast.LENGTH_LONG).show();
                        else
                            Toast.makeText(ModifyCompanyInfo.this, "Mitään ei tapahtunut", Toast.LENGTH_LONG).show();
                    }
                }
        );
    }
}
</code></pre>

<p>And the XML:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.drivopro.drivopro.ModifyCompanyInfo"&gt;

    &lt;EditText
        android:id="@+id/myName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Nimi"
        android:inputType="textPersonName"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintHorizontal_bias="0.503"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        app:layout_constraintVertical_bias="0.084" /&gt;

    &lt;EditText
        android:id="@+id/myAddress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Osoite"
        android:inputType="textPersonName"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintHorizontal_bias="0.503"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        app:layout_constraintVertical_bias="0.0"
        app:layout_constraintTop_toBottomOf="@+id/myName" /&gt;

    &lt;EditText
        android:id="@+id/myZip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Postinumero"
        android:inputType="textPersonName"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintHorizontal_bias="0.503"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@+id/myAddress"
        android:layout_marginBottom="-1dp"
        app:layout_constraintVertical_bias="0.0" /&gt;

    &lt;EditText
        android:id="@+id/myCity"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Kaupunki"
        android:inputType="textPersonName"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintHorizontal_bias="0.503"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="7dp"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@+id/myZip"
        app:layout_constraintVertical_bias="0.0" /&gt;

    &lt;EditText
        android:id="@+id/myPhone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="142dp"
        android:ems="10"
        android:hint="Puhelinnumero"
        android:inputType="textPersonName"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.503"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@+id/myCity"
        app:layout_constraintVertical_bias="0.0" /&gt;

    &lt;Button
        android:id="@+id/cancelChanges"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="poistu"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintHorizontal_bias="0.75"
        app:layout_constraintVertical_bias="0.691" /&gt;

    &lt;Button
        android:id="@+id/saveComp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:text="Save"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.253"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.691" /&gt;
&lt;/android.support.constraint.ConstraintLayout&gt;
</code></pre>

<p>Any help appreciated. Thanks in advance!</p>
