Different local_storage's do not return the different data when the key is the same

when I:
store “one” in local_storage1 with key “thisisit”
store “two” in local_storage2 with key “thisisit” (the same key)

when I:
retrieve key “thisisit” from local_storage1 the result is “two”
retrieve key “thisisit” from local_storage2 the result is “two”

The result from local_storage1 should be “one” because I am using different local_storages

What is happening?

https://x.thunkable.com/projects/60185cb295b0480019e25e98/e9c7b7f4-41fe-4c97-ae02-9098922444ba/blocks

There’s something strange going on for sure.

I would recommend using stored variables instead of local storage: Local Storage - ✕ Docs

Thank you.

I was doubting my results until I decided to make that basic example and came to the conclusion that I was experiencing something odd.

I am now in the process of adding a marker to the key so that every key is unique, to avoid further mix-up.

Why not just use stored variables since that’s the recommendation by Thunkable staff? Or if you need a bunch of them, use a local data source (local db).

I had the same issue with Google sheet based data sources. One of the many reasons I now use firebase exclusively.

1 Like

But this is local storage… not even a spreadsheet. Just individual keys that store data locally on the device. It’s just an outdated way of using stored variables.

Sorry, my bad! I was thinking local db. :flushed:

I am using sets of different data that can be modified locally to be combined to show different results. It needs to be accessible offline, so I have to store the data on the device.

The info on Local DB page says: “At present, changes made to your Local DB data will not be stored across app sessions.”

So it seems that I have no other option than to use either local_storage (which I am using right now) or the stored variables, yes?

1 Like

Yes you are correct. The Local DB does not retain data across sessions but the Local Data Storage does.

You need to note that Local DB is JSON based but Local Data Storage is table based.

Thank you!

Hopefully it’s clear from what @muneer wrote but just in case it’s not, local data storage uses a Local Data Source that you create (table based / spreadsheet) in Thunkable and then pre-populate and/or populate using blocks from the Data Source drawer.

See this: Data Sources - ✕ Docs

1 Like

Thank you!