Android localStorage disappears after erasing an application from RAM

I am using Cordova.webView and trying to use localStorage to cache the username and password of the user. However, although it is assumed that localStorage is solid, I found that every time I remove an application from RAM, localStorage leaves. So how to prevent this?

By β€œerasing an application from RAM,” I mean killing the application process from the background, for example. in Android 4.0, hold down the Home button and click on the cross.

+6
source share
1 answer

In Android 4.4 and 5.0, the local storage for my phone call application is preserved even upon reboot. The only way I know this is to clear the application cache or completely remove the application.

// Store localStorage.lastname = "Smith"; // Retrieve document.getElementById("result").innerHTML = localStorage.lastname; 
0
source

Source: https://habr.com/ru/post/946288/


All Articles