Notepad Tutorial: deleteDatabase() function
- by FelixA
Hello
I have a short question to the notepad tutorial on the android website. I wrote a simple function in the tutorial code to delete the whole database. It looks like this:
DataHelper.java
public void deleteDatabase() {
this.mDb.delete(DATABASE_NAME, null, null);
}
Notepadv1.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
boolean result = super.onCreateOptionsMenu(menu);
menu.add(0, DELETE_ID, 0, "Delete whole Database");
return result;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case DELETE_ID:
mDbHelper.deleteDatabase();
return true;
}
return super.onOptionsItemSelected(item);
}
But when I run the app and try to delete the database I will get this error in LogCat:
sqlite returned: error code = 1, msg= no such table: data
Can you help how to fix this problem. It seems that the function deleteDatabase can not reach the database.
Thank you very much.
Felix