Re-implement deleting and resetting DB
Created by: E3V3A
For some still unknown reason the possibility to clear and reset the AIMSICD DB was removed. The only comments present are these found in AIMSICD.java
} else if (selectedItem.getId() == DrawerMenu.ID.SETTINGS.RESET_DB) {
//Helpers.askAndDeleteDb(this); Todo this isnt a good method for deleting database
// @banjaxbanjo If it isn't good, that it not a good enough reason to remove it.
// or what did you mean?
// "If it ain't broke, don't fix."
Following this lead we get the following code segment in Helpers.java:
/**
* Very cool method. Completely erases the entire database.
* Apply on medical prescription.
* Also asks the user, whether he wants to erase its database ...
*
* @param pContext Context of Activity
*/
public static void askAndDeleteDb(final Context pContext) {
AlertDialog lAlertDialog = new AlertDialog.Builder(pContext)
.setNegativeButton(R.string.open_cell_id_button_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Do nothing
}
})
.setPositiveButton(R.string.open_cell_id_button_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//FIXME need to remove hardcoded string into constants
pContext.deleteDatabase("aimsicd.db");
}
})
.setMessage(pContext.getString(R.string.clear_database_question))
.setTitle(R.string.clear_database)
.setCancelable(false)
.setIcon(R.drawable.ic_action_delete_database).create();
lAlertDialog.show();
}
It's hard to tell if these comments is an attempt to be ironic, so it would be much more appreciated to rather describe the problem or present a method of solution. @banjaxbanjo Can you please explain?