Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在我的sql数据库中插入数据后应用程序崩溃_Android_Database_Sqlite - Fatal编程技术网

Android 在我的sql数据库中插入数据后应用程序崩溃

Android 在我的sql数据库中插入数据后应用程序崩溃,android,database,sqlite,Android,Database,Sqlite,在我点击页面上的每个按钮(按钮更新、inschrijven、showallpople或delete)之后,所有与SQL数据库相关的按钮都会出现。。这是失败的。我不知道为什么,但我认为这与列名有关。我不明白 这是我所有页面的代码 这是我的SQLiteHelper类: package com.example.cedri.myapplication; import android.content.ContentValues; import android.content.Con

在我点击页面上的每个按钮(按钮更新、inschrijven、showallpople或delete)之后,所有与SQL数据库相关的按钮都会出现。。这是失败的。我不知道为什么,但我认为这与列名有关。我不明白

这是我所有页面的代码

这是我的SQLiteHelper类:

      package com.example.cedri.myapplication;

     import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
* Created by cedri on 17/05/2016.
*/

public class DatabaseHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME= "KIND_DATABASE.db";
public static final String TABLE_NAME= "KIND_TABLE";
public static final int DATABASE_VERSION=1;

public static final String COL_1="ID";
public static final String COL_2="VOORNAAM";
public static final String COL_3="NAAM";
public static final String COL_4="LEEFTIJD";
public static final String COL_5="EMAIL";

private static final String CREATE_TABLE_KIND= "create table "+TABLE_NAME + " ( " +
        COL_1 +" INTEGER PRIMARY KEY AUTOINCREMENT," +
        COL_2+" TEXT," +
        COL_3+ " TEXT," +
        COL_4+ " INTEGER," +
        COL_5+" TEXT);";

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

}

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(CREATE_TABLE_KIND);
}

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

public boolean insertData(String voornaam,String naam,Integer leeftijd,String email){
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues=new ContentValues();
    contentValues.put(COL_2,voornaam);
    contentValues.put(COL_3,naam);
    contentValues.put(COL_4,leeftijd);
    contentValues.put(COL_5, email);

    long result= db.insert(TABLE_NAME,null,contentValues);
    if(result==-1){
        return false;
    }
    else{
        return true;
    }
}

public Cursor getAllData(){
    SQLiteDatabase db=this.getWritableDatabase();
    Cursor res=db.rawQuery("select * from "+TABLE_NAME,null);

    return res;
}

public Integer deleteData(String email){
    SQLiteDatabase db=this.getWritableDatabase();
    return db.delete(TABLE_NAME,"EMAIL=?",new String[]{email});

}

public boolean updateData(String voornaam, String naam, Integer leeftijd, String email){
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();

    contentValues.put(COL_2,voornaam);
    contentValues.put(COL_3,naam);
    contentValues.put(COL_4,leeftijd);
    contentValues.put(COL_5, email);
    db.update(TABLE_NAME,contentValues,"EMAIL = ?",new String[]{email});
    return true;

}
}
public class MainActivity extends AppCompatActivity
        implements         NavigationView.OnNavigationItemSelectedListener,menu3Fragment.OnMainFragmentInteractionListener {

DatabaseHelper myDb;
TextView txtVoornaam,txtNaam,txtLeeftijd,txtEmail;

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    myDb = new DatabaseHelper(this);
}

public void btnUpdate_Click(View view){
    boolean isUpdate = myDb.updateData(txtVoornaam.getText().toString(),
            txtNaam.getText().toString(),
            Integer.valueOf(txtLeeftijd.getText().toString()),
            txtEmail.getText().toString());

    if(isUpdate==true){
        Toast.makeText(MainActivity.this,"De data is geupdate",Toast.LENGTH_LONG).show();
    }
    else{
        Toast.makeText(MainActivity.this,"De data is niet geupdate",Toast.LENGTH_LONG).show();
    }
}
public void btnDelete_Click(View view){
    Integer isDelete = myDb.deleteData(
            txtEmail.getText().toString());

    if(isDelete>1){
        Toast.makeText(MainActivity.this,"De data is verwijderd",Toast.LENGTH_LONG).show();
    }
    else{
        Toast.makeText(MainActivity.this,"De data is niet verwijderd",Toast.LENGTH_LONG).show();
    }
}
public void btnGaNaarIngeschrevenLeden_Click(View view) {

    Cursor res=myDb.getAllData();
    if(res.getCount() == 0){
        //show message
        showMessage("Error", "Er werd geen data gevonden");
        return;
    }

    StringBuffer buffer = new StringBuffer();
    while(res.moveToNext()){
        buffer.append("Id :"+ res.getString(0) + "\n");
        buffer.append("Voornaam :"+ res.getString(1) + "\n");
        buffer.append("Naam :"+ res.getString(2) + "\n");
        buffer.append("Leeftijd :"+ res.getInt(3) + "\n");
        buffer.append("Email :"+ res.getString(4) + "\n\n");
    }

    //show all data
    showMessage("Ingeschreven kinderen 2016", buffer.toString());
}
public void btnSchrijfIn_Click(View view) {
    txtVoornaam= (TextView)findViewById(R.id.Voornaam);
    txtNaam= (TextView)findViewById(R.id.Naam);
    txtLeeftijd= (TextView)findViewById(R.id.Leeftijd);
    txtEmail= (TextView)findViewById(R.id.Email);

    boolean isInsertData =
            myDb.insertData(
                    txtVoornaam.getText().toString(),
                    txtNaam.getText().toString(),
                    Integer.valueOf(txtLeeftijd.getText().toString()),
                    txtEmail.getText().toString() );

    if(isInsertData==true){
        //sendEmail();
        Toast.makeText(MainActivity.this,"Uw kind werd succesvol ingeschreven!", Toast.LENGTH_LONG).show();
    }
    else
    {
        TextView foutmelding2=(TextView)findViewById(R.id.Foutmelding);
        foutmelding2.setVisibility(TextView.VISIBLE);
    }

    Fragment fragment = new menu1Fragment();
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction transaction =fragmentManager.beginTransaction();
    transaction.replace(R.id.main_content,fragment);
    transaction.addToBackStack(null);
    transaction.commit();
}
    <?xml version="1.0" encoding="utf-8"?>
         <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.cedri.chiroeine.InschrijvenPage"
android:background="@color/backgroundzwart">

<TextView
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:gravity="center"
    android:text="@string/Inschrijving_titel"
    android:drawableLeft="@drawable/test"
    android:layout_marginLeft="45dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="15dp"
    android:textSize="20dp"
    android:textColor="@color/achtergrond_inputvak"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_marginLeft="20dp"
    android:layout_marginTop="50dp">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak1"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="58dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Voornaam"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak2"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="95dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Naam"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak3"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="82dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Leeftijd"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak4"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="100dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Email"/>

    </LinearLayout>
</LinearLayout>



<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text=""
    android:layout_marginLeft="25dp"
    android:layout_marginRight="75dp"
    android:layout_marginTop="35dp"
    android:textColor="@color/rooderror"
    android:id="@+id/Foutmelding"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Inschrijving_btn_SchrijfIn"
android:background="@drawable/rounded_btn"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:layout_marginLeft="200dp"
android:id="@+id/SchrijfIn"
android:drawableLeft="@drawable/arrow"
android:onClick="btnSchrijfIn_Click"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginTop="10dp">


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Inschrijving_btn_GaNaarIngeschrevenLeden"
        android:background="@drawable/rounded_btn"
        android:paddingLeft="5dp" android:paddingRight="5dp"
        android:layout_marginLeft="10dp"
        android:onClick="btnGaNaarIngeschrevenLeden_Click"/>

    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/UpdateText"
    android:background="@drawable/rounded_btn"
    android:layout_marginLeft="10dp"
    android:paddingLeft="5dp" android:paddingRight="5dp"
    android:onClick="btnUpdate_Click"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/DeleteText"
        android:background="@drawable/rounded_btn"
        android:layout_marginLeft="10dp"
        android:paddingLeft="5dp" android:paddingRight="5dp"
        android:onClick="btnDelete_Click"/>

 </LinearLayout>




</LinearLayout>
这是我的主要活动课程:

      package com.example.cedri.myapplication;

     import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
* Created by cedri on 17/05/2016.
*/

public class DatabaseHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME= "KIND_DATABASE.db";
public static final String TABLE_NAME= "KIND_TABLE";
public static final int DATABASE_VERSION=1;

public static final String COL_1="ID";
public static final String COL_2="VOORNAAM";
public static final String COL_3="NAAM";
public static final String COL_4="LEEFTIJD";
public static final String COL_5="EMAIL";

private static final String CREATE_TABLE_KIND= "create table "+TABLE_NAME + " ( " +
        COL_1 +" INTEGER PRIMARY KEY AUTOINCREMENT," +
        COL_2+" TEXT," +
        COL_3+ " TEXT," +
        COL_4+ " INTEGER," +
        COL_5+" TEXT);";

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

}

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(CREATE_TABLE_KIND);
}

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

public boolean insertData(String voornaam,String naam,Integer leeftijd,String email){
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues=new ContentValues();
    contentValues.put(COL_2,voornaam);
    contentValues.put(COL_3,naam);
    contentValues.put(COL_4,leeftijd);
    contentValues.put(COL_5, email);

    long result= db.insert(TABLE_NAME,null,contentValues);
    if(result==-1){
        return false;
    }
    else{
        return true;
    }
}

public Cursor getAllData(){
    SQLiteDatabase db=this.getWritableDatabase();
    Cursor res=db.rawQuery("select * from "+TABLE_NAME,null);

    return res;
}

public Integer deleteData(String email){
    SQLiteDatabase db=this.getWritableDatabase();
    return db.delete(TABLE_NAME,"EMAIL=?",new String[]{email});

}

public boolean updateData(String voornaam, String naam, Integer leeftijd, String email){
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();

    contentValues.put(COL_2,voornaam);
    contentValues.put(COL_3,naam);
    contentValues.put(COL_4,leeftijd);
    contentValues.put(COL_5, email);
    db.update(TABLE_NAME,contentValues,"EMAIL = ?",new String[]{email});
    return true;

}
}
public class MainActivity extends AppCompatActivity
        implements         NavigationView.OnNavigationItemSelectedListener,menu3Fragment.OnMainFragmentInteractionListener {

DatabaseHelper myDb;
TextView txtVoornaam,txtNaam,txtLeeftijd,txtEmail;

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    myDb = new DatabaseHelper(this);
}

public void btnUpdate_Click(View view){
    boolean isUpdate = myDb.updateData(txtVoornaam.getText().toString(),
            txtNaam.getText().toString(),
            Integer.valueOf(txtLeeftijd.getText().toString()),
            txtEmail.getText().toString());

    if(isUpdate==true){
        Toast.makeText(MainActivity.this,"De data is geupdate",Toast.LENGTH_LONG).show();
    }
    else{
        Toast.makeText(MainActivity.this,"De data is niet geupdate",Toast.LENGTH_LONG).show();
    }
}
public void btnDelete_Click(View view){
    Integer isDelete = myDb.deleteData(
            txtEmail.getText().toString());

    if(isDelete>1){
        Toast.makeText(MainActivity.this,"De data is verwijderd",Toast.LENGTH_LONG).show();
    }
    else{
        Toast.makeText(MainActivity.this,"De data is niet verwijderd",Toast.LENGTH_LONG).show();
    }
}
public void btnGaNaarIngeschrevenLeden_Click(View view) {

    Cursor res=myDb.getAllData();
    if(res.getCount() == 0){
        //show message
        showMessage("Error", "Er werd geen data gevonden");
        return;
    }

    StringBuffer buffer = new StringBuffer();
    while(res.moveToNext()){
        buffer.append("Id :"+ res.getString(0) + "\n");
        buffer.append("Voornaam :"+ res.getString(1) + "\n");
        buffer.append("Naam :"+ res.getString(2) + "\n");
        buffer.append("Leeftijd :"+ res.getInt(3) + "\n");
        buffer.append("Email :"+ res.getString(4) + "\n\n");
    }

    //show all data
    showMessage("Ingeschreven kinderen 2016", buffer.toString());
}
public void btnSchrijfIn_Click(View view) {
    txtVoornaam= (TextView)findViewById(R.id.Voornaam);
    txtNaam= (TextView)findViewById(R.id.Naam);
    txtLeeftijd= (TextView)findViewById(R.id.Leeftijd);
    txtEmail= (TextView)findViewById(R.id.Email);

    boolean isInsertData =
            myDb.insertData(
                    txtVoornaam.getText().toString(),
                    txtNaam.getText().toString(),
                    Integer.valueOf(txtLeeftijd.getText().toString()),
                    txtEmail.getText().toString() );

    if(isInsertData==true){
        //sendEmail();
        Toast.makeText(MainActivity.this,"Uw kind werd succesvol ingeschreven!", Toast.LENGTH_LONG).show();
    }
    else
    {
        TextView foutmelding2=(TextView)findViewById(R.id.Foutmelding);
        foutmelding2.setVisibility(TextView.VISIBLE);
    }

    Fragment fragment = new menu1Fragment();
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction transaction =fragmentManager.beginTransaction();
    transaction.replace(R.id.main_content,fragment);
    transaction.addToBackStack(null);
    transaction.commit();
}
    <?xml version="1.0" encoding="utf-8"?>
         <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.cedri.chiroeine.InschrijvenPage"
android:background="@color/backgroundzwart">

<TextView
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:gravity="center"
    android:text="@string/Inschrijving_titel"
    android:drawableLeft="@drawable/test"
    android:layout_marginLeft="45dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="15dp"
    android:textSize="20dp"
    android:textColor="@color/achtergrond_inputvak"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_marginLeft="20dp"
    android:layout_marginTop="50dp">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak1"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="58dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Voornaam"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak2"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="95dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Naam"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak3"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="82dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Leeftijd"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak4"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="100dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Email"/>

    </LinearLayout>
</LinearLayout>



<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text=""
    android:layout_marginLeft="25dp"
    android:layout_marginRight="75dp"
    android:layout_marginTop="35dp"
    android:textColor="@color/rooderror"
    android:id="@+id/Foutmelding"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Inschrijving_btn_SchrijfIn"
android:background="@drawable/rounded_btn"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:layout_marginLeft="200dp"
android:id="@+id/SchrijfIn"
android:drawableLeft="@drawable/arrow"
android:onClick="btnSchrijfIn_Click"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginTop="10dp">


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Inschrijving_btn_GaNaarIngeschrevenLeden"
        android:background="@drawable/rounded_btn"
        android:paddingLeft="5dp" android:paddingRight="5dp"
        android:layout_marginLeft="10dp"
        android:onClick="btnGaNaarIngeschrevenLeden_Click"/>

    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/UpdateText"
    android:background="@drawable/rounded_btn"
    android:layout_marginLeft="10dp"
    android:paddingLeft="5dp" android:paddingRight="5dp"
    android:onClick="btnUpdate_Click"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/DeleteText"
        android:background="@drawable/rounded_btn"
        android:layout_marginLeft="10dp"
        android:paddingLeft="5dp" android:paddingRight="5dp"
        android:onClick="btnDelete_Click"/>

 </LinearLayout>




</LinearLayout>
这是我的布局文件:

      package com.example.cedri.myapplication;

     import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
* Created by cedri on 17/05/2016.
*/

public class DatabaseHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME= "KIND_DATABASE.db";
public static final String TABLE_NAME= "KIND_TABLE";
public static final int DATABASE_VERSION=1;

public static final String COL_1="ID";
public static final String COL_2="VOORNAAM";
public static final String COL_3="NAAM";
public static final String COL_4="LEEFTIJD";
public static final String COL_5="EMAIL";

private static final String CREATE_TABLE_KIND= "create table "+TABLE_NAME + " ( " +
        COL_1 +" INTEGER PRIMARY KEY AUTOINCREMENT," +
        COL_2+" TEXT," +
        COL_3+ " TEXT," +
        COL_4+ " INTEGER," +
        COL_5+" TEXT);";

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

}

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(CREATE_TABLE_KIND);
}

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

public boolean insertData(String voornaam,String naam,Integer leeftijd,String email){
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues=new ContentValues();
    contentValues.put(COL_2,voornaam);
    contentValues.put(COL_3,naam);
    contentValues.put(COL_4,leeftijd);
    contentValues.put(COL_5, email);

    long result= db.insert(TABLE_NAME,null,contentValues);
    if(result==-1){
        return false;
    }
    else{
        return true;
    }
}

public Cursor getAllData(){
    SQLiteDatabase db=this.getWritableDatabase();
    Cursor res=db.rawQuery("select * from "+TABLE_NAME,null);

    return res;
}

public Integer deleteData(String email){
    SQLiteDatabase db=this.getWritableDatabase();
    return db.delete(TABLE_NAME,"EMAIL=?",new String[]{email});

}

public boolean updateData(String voornaam, String naam, Integer leeftijd, String email){
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();

    contentValues.put(COL_2,voornaam);
    contentValues.put(COL_3,naam);
    contentValues.put(COL_4,leeftijd);
    contentValues.put(COL_5, email);
    db.update(TABLE_NAME,contentValues,"EMAIL = ?",new String[]{email});
    return true;

}
}
public class MainActivity extends AppCompatActivity
        implements         NavigationView.OnNavigationItemSelectedListener,menu3Fragment.OnMainFragmentInteractionListener {

DatabaseHelper myDb;
TextView txtVoornaam,txtNaam,txtLeeftijd,txtEmail;

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    myDb = new DatabaseHelper(this);
}

public void btnUpdate_Click(View view){
    boolean isUpdate = myDb.updateData(txtVoornaam.getText().toString(),
            txtNaam.getText().toString(),
            Integer.valueOf(txtLeeftijd.getText().toString()),
            txtEmail.getText().toString());

    if(isUpdate==true){
        Toast.makeText(MainActivity.this,"De data is geupdate",Toast.LENGTH_LONG).show();
    }
    else{
        Toast.makeText(MainActivity.this,"De data is niet geupdate",Toast.LENGTH_LONG).show();
    }
}
public void btnDelete_Click(View view){
    Integer isDelete = myDb.deleteData(
            txtEmail.getText().toString());

    if(isDelete>1){
        Toast.makeText(MainActivity.this,"De data is verwijderd",Toast.LENGTH_LONG).show();
    }
    else{
        Toast.makeText(MainActivity.this,"De data is niet verwijderd",Toast.LENGTH_LONG).show();
    }
}
public void btnGaNaarIngeschrevenLeden_Click(View view) {

    Cursor res=myDb.getAllData();
    if(res.getCount() == 0){
        //show message
        showMessage("Error", "Er werd geen data gevonden");
        return;
    }

    StringBuffer buffer = new StringBuffer();
    while(res.moveToNext()){
        buffer.append("Id :"+ res.getString(0) + "\n");
        buffer.append("Voornaam :"+ res.getString(1) + "\n");
        buffer.append("Naam :"+ res.getString(2) + "\n");
        buffer.append("Leeftijd :"+ res.getInt(3) + "\n");
        buffer.append("Email :"+ res.getString(4) + "\n\n");
    }

    //show all data
    showMessage("Ingeschreven kinderen 2016", buffer.toString());
}
public void btnSchrijfIn_Click(View view) {
    txtVoornaam= (TextView)findViewById(R.id.Voornaam);
    txtNaam= (TextView)findViewById(R.id.Naam);
    txtLeeftijd= (TextView)findViewById(R.id.Leeftijd);
    txtEmail= (TextView)findViewById(R.id.Email);

    boolean isInsertData =
            myDb.insertData(
                    txtVoornaam.getText().toString(),
                    txtNaam.getText().toString(),
                    Integer.valueOf(txtLeeftijd.getText().toString()),
                    txtEmail.getText().toString() );

    if(isInsertData==true){
        //sendEmail();
        Toast.makeText(MainActivity.this,"Uw kind werd succesvol ingeschreven!", Toast.LENGTH_LONG).show();
    }
    else
    {
        TextView foutmelding2=(TextView)findViewById(R.id.Foutmelding);
        foutmelding2.setVisibility(TextView.VISIBLE);
    }

    Fragment fragment = new menu1Fragment();
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction transaction =fragmentManager.beginTransaction();
    transaction.replace(R.id.main_content,fragment);
    transaction.addToBackStack(null);
    transaction.commit();
}
    <?xml version="1.0" encoding="utf-8"?>
         <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.cedri.chiroeine.InschrijvenPage"
android:background="@color/backgroundzwart">

<TextView
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:gravity="center"
    android:text="@string/Inschrijving_titel"
    android:drawableLeft="@drawable/test"
    android:layout_marginLeft="45dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="15dp"
    android:textSize="20dp"
    android:textColor="@color/achtergrond_inputvak"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_marginLeft="20dp"
    android:layout_marginTop="50dp">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak1"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="58dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Voornaam"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak2"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="95dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Naam"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak3"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="82dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Leeftijd"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Inschrijving_inputvak4"
            android:textColor="@color/bordeaurood"
            android:textSize="20dp"/>

        <EditText
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:layout_marginLeft="100dp"
            android:layout_marginRight="15dp"
            android:background="@color/achtergrond_inputvak"
            android:id="@+id/Email"/>

    </LinearLayout>
</LinearLayout>



<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text=""
    android:layout_marginLeft="25dp"
    android:layout_marginRight="75dp"
    android:layout_marginTop="35dp"
    android:textColor="@color/rooderror"
    android:id="@+id/Foutmelding"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Inschrijving_btn_SchrijfIn"
android:background="@drawable/rounded_btn"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:layout_marginLeft="200dp"
android:id="@+id/SchrijfIn"
android:drawableLeft="@drawable/arrow"
android:onClick="btnSchrijfIn_Click"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginTop="10dp">


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Inschrijving_btn_GaNaarIngeschrevenLeden"
        android:background="@drawable/rounded_btn"
        android:paddingLeft="5dp" android:paddingRight="5dp"
        android:layout_marginLeft="10dp"
        android:onClick="btnGaNaarIngeschrevenLeden_Click"/>

    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/UpdateText"
    android:background="@drawable/rounded_btn"
    android:layout_marginLeft="10dp"
    android:paddingLeft="5dp" android:paddingRight="5dp"
    android:onClick="btnUpdate_Click"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/DeleteText"
        android:background="@drawable/rounded_btn"
        android:layout_marginLeft="10dp"
        android:paddingLeft="5dp" android:paddingRight="5dp"
        android:onClick="btnDelete_Click"/>

 </LinearLayout>




</LinearLayout>

日志显示您正试图将数据库从版本200降级为1。
ondownggrade()
的默认实现拒绝任何降级,并抛出日志中可见的异常

解决方案
:在应用程序中覆盖
onDowngrade()
,或者卸载并重新安装应用程序

代码中有一个错误-EXISTS和表名之间需要有一个空格

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

给我们看看日志。如果不阅读logcat,任何人都无法猜到你的应用程序中发生了什么。欢迎使用StackOverflow!为了帮助其他人理解您的问题,请发布代码示例、任何日志的输出(例如LogCat)或其他东西,以演示您的问题。但是我尝试过,但他们认为这是垃圾邮件,截图好吗?对于引发的异常,请用LogCat输出替换布局代码。卸载并重新安装应用程序。您的数据库中存在一些不一致之处。如果答案对你有帮助,就接受它。你做得很好,我的朋友!真的谢谢!!我是新来的,我必须达到前15名的声誉:/抱歉,但真的谢谢!您可以通过单击勾号符号来接受。它不需要名声。