Localstorage deleted inconsistently -> local file backups?

I am using localstorage to save user data in my prototype implementation. I am testing the app exhaustively and using it. However, one of my users managed for the second time to somehow delete the storage. There is only one location in the code where I overwrite my window.localstorage[‘myStorage’] .

However, it seems to not be as stable as I hoped for. Hence, I first must create a fix where I backup the data. It would be better to store it in the cloud, but that’s too much work for now.
I am aiming at local file backups for now as a workaround till I figure where the error is.
Any other suggestions?

I suspect some inconsistent state in the app like recieving a text message or a call to be the reason.

You can try using PouchDB. It’s pretty straight forward and safe.

Ok, I’ll have a look into it. Anything else about the potential inconsistencies. I know this is like fortune telling because the code is not shared…

Read this

Basically the LocalStorage can be cleared by the system when the memory is low.

Interesting!
It was on iOS by the way.
Reading through the links you sent. Thanks!