hive
hive copied to clipboard
all box data is lost if app killed in background.
Steps to Reproduce
1- Initialize hive DB and open a box.
2- put some keys with values in the box.
3- after putting data into the box call await box.close()
.
4- In Android show all open apps. and close the app window.
5- reopen the app, and all data is cleared now.
Code sample
var box = await openBox('reports');
reports.add(report);
try {
box.put('allreports', reports);
await box.close();
} catch (e) {
printLog('error; $e');
}
Version
- Platform: iOS (15.0.4) , Android (12.0)
- Flutter version: [e.g. 1.5.4]
- Hive version: [e.g. 0.5.0]
Having a similar issue on Windows desktop as well
This sounds like similar behavior to this issue. Consider reverting to 2.0.0 or testing which version introduced this issue?
@andy98725
as our deadline was close I just converted all my database to sqflite
(SQlite). It was a huge thing but couldn't find any workaround for this issue with HiveDB.
i switched too. first look is nice but fail recovery is basically not there. no way to force persist data no way to force reload data from disk. thats not good...
Any suggestions or solution yet?
@kechankrisna I personally switched to sqflite
.
Any suggestions or solution yet?
I do flush all boxes on AppLifecycleState changed to inactive. It works for me.
Any suggestions or solution yet?
I do flush all boxes on AppLifecycleState changed to inactive. It works for me.
How ?
Any suggestions or solution yet?
I do flush all boxes on AppLifecycleState changed to inactive. It works for me.
How ?
https://github.com/alexandrim0/keyper/blob/main/lib/src/home/home_view.dart
Any solution here except the workaround?
Just to make this issue clear the workaround suggested by @alexandrim0 is currently the best solution to prevent losing data.
@SebghatYusuf, can you reproduce if you do await box.put('allreports', reports)
instead of just box.put('allreports', reports)
in your example?