Skip to content Skip to sidebar Skip to footer

How To Delete Database In Android App

How can I delete the database from the application?

Solution 1:

Did you check deleteDatabase() method available in Android?

Solution 2:

FiledbFile= getDatabasePath("your_db_file_name");
booleandeleted= dbFile.delete();

Solution 3:

Old post, but I think its worth adding this in case this feature wasn't available back then. I use Context. For example, when your in MainActivity

this.deleteDatabase("mydata.db");

or when you have a context handle elsewhere

context.deleteDatabase("mydata.db");

Solution 4:

Do you need to delete the actual db file or is it enough to just DROP the tables? I'd imagine the end result is the same and dropping the tables could be easier.

Post a Comment for "How To Delete Database In Android App"