Notepad Tutorial: deleteDatabase() function

Posted by FelixA on Stack Overflow See other posts from Stack Overflow or by FelixA
Published on 2010-12-25T08:36:28Z Indexed on 2010/12/25 8:54 UTC
Read the original article Hit count: 194

Filed under:
|
|
|
|

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

© Stack Overflow or respective owner

Related posts about android

Related posts about database