hive
hive copied to clipboard
Clear boxes
Question Hi guys, what I want to do is delete all the data from the boxes and start saving data again. I did the next method to reset the boxes, but I get this error: "the box has been closed". How could I re-open the boxes once they are closed or how to complete clear boxes and memory ? Thank you very much for your answers : )
Code sample
Future resetBoxes() async {
// clear
await usersBOX.clear();
await expensesBOX.clear();
// compact
await usersBOX.compact();
await expensesBOX.compact();
// close
await Hive.close();
// re open boxes
await Hive.openBox<UserModel>('USERS-BOX');
await Hive.openBox<ExpenseModel>('EXPENSE-BOX');
}
Version
- Platform: Android
- Flutter version: 2.5
- Hive version: 2.0.4
Delete the box from entirely.
usersBox.deleteFromDisk()
@keezysilencer deleteFromDisk() isn't working