Delete Item with Button click

In my MainActivity i want my button to delete all items in my view list. Unfortunately all the solutions i found here won’t help me. If i click on the Button “Clear All” it deletes every item in my list, but the items are still saved in my Database.

I am totally new to Android Studio, so i donĀ“t know how to write my code that it will work the way i want it.

This is my MainActivity:

package com.vorlesung.iubh.todo;  import android.content.Context; import android.content.Intent; import android.database.Cursor; import; import android.os.Bundle; import android.util.SparseBooleanArray; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.Toast;  import java.util.ArrayList;  public class MainActivity extends AppCompatActivity {      DatabaseHepler myDB;     ArrayList<String> list;     ListView myToDoList;     ArrayAdapter<String> arrayAdapter;     SparseBooleanArray selectedItem;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          Button addToDo = (Button) findViewById(;         Button clearAll = (Button) findViewById(;         Button editSelected = (Button) findViewById(;         Button clearDone = (Button) findViewById(;          myToDoList = (ListView) findViewById(;         myDB = new DatabaseHepler(this);          list = new ArrayList<>();         Cursor data = myDB.getListContents();          if (data.getCount() == 0)             Toast.makeText(this, "The Database was empty",         Toast.LENGTH_LONG).show();         else {             while (data.moveToNext()) {                 list.add(data.getString(1));                 arrayAdapter = new ArrayAdapter<>(this,     android.R.layout.simple_list_item_multiple_choice, list);                 myToDoList.setAdapter(arrayAdapter);             }         }     }      public void onClickaddToDo(View button) {         Intent newToDo = new Intent(this, AddToDo.class);         startActivity(newToDo);     }      // With this onClick i want to delete all Items from my List.     public void onClickaclearALL(View button) {         list.clear();         arrayAdapter.notifyDataSetChanged();     } } 

And this is my DataBase:

package com.vorlesung.iubh.todo;  import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper;  public class DatabaseHepler extends SQLiteOpenHelper {      public static final String DATABASE_NAME = "myList.db";     public static final String TABLE_NAME = "myList_Data";     public static final String COL1 = "ID";     public static final String COL2 = "ITEM1";      public DatabaseHepler(Context context){super(context, DATABASE_NAME, null, 1);}      @Override     public void onCreate(SQLiteDatabase db) {         String createTable = "CREATE TABLE " + TABLE_NAME + " (ID INTEGER PRIMARY KEY AUTOINCREMENT, " + "ITEM1 TEXT)";         db.execSQL(createTable);     }      @Override     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){         db.execSQL("DROP IF TABLE EXISTS " + TABLE_NAME);     }      public boolean addData(String item1) {         SQLiteDatabase db = this.getWritableDatabase();         ContentValues contentValues = new ContentValues();         contentValues.put(COL2, item1);          long result = db.insert(TABLE_NAME, null, contentValues);          if(result == -1) {             return false;         } else {             return true;         }     }      public Cursor getListContents() {         SQLiteDatabase db = this.getWritableDatabase();         Cursor data = db.rawQuery("SELECT * FROM " + TABLE_NAME, null);         return data;     }      public void deleteRow() {         SQLiteDatabase db = this.getWritableDatabase();         db.execSQL("DELETE FROM " + TABLE_NAME+ " WHERE "+ COL2, null);         db.close();     }  } 

Hope someone can show me the way how to do that.