jeudi 5 mai 2016

How to refresh a ListView when I delete all SQLite table data in Android

I have a listview with elements coming from a SQLite table, when I delete the contents of the table and try to refresh the listview I get a null exception

I do the following

mHelper.clearDatabase("TableName");
Adapter.clear();
Adapter.notifyDataSetChanged();

public void clearDatabase(String TABLE_NAME) {
    SQLiteDatabase db = this.getWritableDatabase();
    String clearDBQuery = "DELETE FROM "+TABLE_NAME;
    db.execSQL(clearDBQuery);
}

How I am going to refresh my listview from a table which contains nothing?

Aucun commentaire:

Enregistrer un commentaire