Cordova > Capacitor localStorage missing?

I have an established Cordova app that uses localstorage extensively. After moving to Capacitor, all localstorage data is missing - I’m assuming this is because of the change in url scheme because the data still exists if I downgrade back to the Cordova implementation.

Does anyone know the default scheme for Cordova Android? Or a way to figure out what it is? Then I can configure Capacitor to use the “old” scheme.

There are some notes about this in the Capacitor docs, but nothing relating specifically to Android Cordova to Capacitor migration.

So after trying many different things, it turns out the default URL scheme for Cordova is “file” so setting capacitor.config to:

“server”: {
“androidScheme”: “file”

will get you access to any Cordova localStorage data on your new migrated Capacitor project.

I tried this, but if I change “androidScheme” to “file” then the app won’t load any more. (Capacitor 3 RC0).

You are lucky if you have been using cordova-plugin-ionic-webview because this sets the scheme to “http” so upgrading to Capacitor should keep the localStorage entries.

Hi. I’m using Capacitor 3 to create a new release to my WebApp migrating from Cordova.

The app by Cap3 is losing my localStorage data… Because is loaded in http://localhost instead of file://android_asset… like in cordova before.
I’m trying to use the conf “server”: { “androidScheme”: “file” } but now I’m facing the error:

The webpage at file://localhost could not be loaded because: net::ERR_ACCESS_DENIED

1 Like

How about iOS? This solution seems strict android?

EDIT: Found “iosScheme” :slight_smile:

can you mention which version of capacitor and android version was used…

I am facing the same issue… Please can you tell me which version of Capacitor you used so that androidScheme: file worked for you ?

Please any hint will be very helpful … Need to update the app and the data from localstorage is lost. For iOS it works…