I am running an electron app, where in its renderer process I use HTML5 localStorage.
I\'m interested to know where in my file-system is this localStorage actually sto
It's stored in the AppData folder, which you can find by looking at the value of require('app').getPath('userData')
.
This means the data persists even if the app is deleted. If you're running two instances, you'll need to find some way of distinguishing between them so they don't trample on each other's data.
I had to use the following in my Electron app to get it working:
const remote = require('electron').remote;
const app = remote.app;
app.getPath('userData');
However, the path where it stores the data is under:
\Local Storage\leveldb\
So your entire path will look something like:
C:\Users\<USER-NAME>\AppData\Roaming\<APP-NAME>\Local Storage\leveldb\
Log File : Not Sqlite DB Even though the browser (FireFox in my case) stores localStorage data in a sqlite file, it seems that Electron does not.
Instead, it saves the data in a an odd .log file mine was named 000003.log
.
Here's what it looks like after I ran three localStorage.setItem() commands from my app's console.
Here's a look at the console of my Electron app where I ran the three commands. You can match up the commands with the data in the 000003.log file if you look closely at the images.
Further Proof This Is the Storage Location/Mechanism
If I run localStorage.getItem("fakeData") in my console then the value is returned.
However, if you :
You will get no value returned.
Now to complete the cycle:
You'll see the value again.
LevelDB : Google Thing
I was contemplating that crazy format and then I thought about the name of that final directory (leveldb). I did a duckduckgo and found this: https://github.com/google/leveldb
So I'm guessing that is the format since Electron is using the Chrome engine.
From Wikipedia :
LevelDB is an open-source on-disk key-value store written by Google fellows Jeffrey Dean and Sanjay Ghemawat. Inspired by Bigtable, LevelDB is hosted on GitHub under the New BSD License and has been ported to a variety of Unix-based systems, macOS, Windows, and Android.