Deleting user database

DBOpenHelper or SQLiteDatabase doesn't have functions to delete the database. Looks like there are people who are using file delete by going to the database location and deleting the file programmatically. The easier solution is : Android does provide the mechanism to delete the file. It's available in ApplicationContext though.

You would do something like this:

InstantReturn app = (InstantReturn) getApplicationContext();

// dbHelperInstance.close();
// dbInstance.close();

if (app.deleteDatabase(DatabaseOpenHelper.DB_NAME)) {
Log.d(ViewConstant.APPLICATION_NAME, "deleteDatabase(): database deleted.");
} else {
Log.d(ViewConstant.APPLICATION_NAME, "deleteDatabase(): database NOT deleted.");
}

Comments

Popular posts from this blog

Temples in Bangalore!

Blogspot.in?

Booked my first car!