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.");


Popular posts from this blog

TextWrangler and formating XML & JSON Documents

MyLife-Happy Days Facebook App to track your happiness

Http Post utility