I have found many questions regarding local storage but most of them are just unanswered, so hoping for the best with mine.
We do have a database of the airport in the Firebase. That is around 3500 documents each with 6 rows of text, that’s around 21K rows of text and I was wondering if local storage is something I can use in this case to avoid long loading time on the user’s side and take the heavy lifting out of our BE.
Therefore I do have a few questions regarding this:
- For how long is that local storage stored?
- How much data I can store on the Local storage?
- Do you have any idea, how much data that would be? I guess that 21K rows of the text should not be that much, however, I wanna make sure and ask if someone else was doing something similar.
- How should I proceed in order to load the data to the local storage. In one of your videos I have seen that you are using “Get record collection” and “Create a record”, however, there are also options “Set item to local storage” and “Get item from local storage” which way is the right one to work with the local storage, please?
I have similar issue as mentioned HERE that database does not match the local storage scheme, even though it’s the same, however, I guess I can find a workaround here via manual mapping.
Pretty please @appgyver
Well, the thing with local storage is that it’s, well, local on the user’s device. As such, the amount of storage you can take depends on how much each specific user happens to have storage space left on their device – so it’s impossible to tell.
Here is quite a good thread on using on-device storage and get/set storage item flows, hopefully this would help you!
Mevi, I have managed to connect via create records, verifying through debugger and getting them back directly from the data.variable fairly easy.
As much as I’ve spent time going over the set and get item examples, I can’t peice this method together. Most of the examples are from someone who completely understands their data and you gurus who easily pick up what they are talking about. One way or another steps are left out for us that are not familiar with the method.
I feel that it is super simple because set /get doesn’t ask for much, but that simple is what is getting me. Even though I havey stuff working, not knowing this buggs me because I feel this can work better for me.
If you outlined step by step approach, I feel alot of the same questions would not be asked.
Regardless, I appreciate all you guys do.
Hey @Luis_Hernandez I’ll try to answer your questions based on my experiences using On-device storage. But first…what does your data look like? I didn’t really understand what you meant by a document with 6 rows of text unless you’re talking about a text file or something.
- I assume the data will last as long as the user doesn’t delete the application.
- I don’t see any limitation other than the actual storage space on a users device.
- This depends on what a “row” of text is I guess. I’ve stored around 2,000 records (mostly text fields) on a device without any problems. I would guess most modern phones could handle A LOT of text data.
- I do this part by looping over the results from a Get Collection (data from API) function and storing the data using On-device storage. It looks something like this…
It was actually Jaroslav_Krajca who asked the question and thanks for your help. I have figured out how to copy data from rest api to device with some help and retrieve it to show up when app is restarted without any get method or get record method. Just linking the data. Veriable to a read only field.
Mevi’s suggestion to Jaroslav_Krajca was to use set and get item from storage. That is what I feel maybe super simple but through all the information I’ve gone over I feel it’s not too clear on how they use that method. I was just hoping and at the same time clear up the confusion since it was suggested for Jaroslav_Krajca to look into.
Save data to appvar (objects) - - > to data.Variable ( on-device). This works good.
Pull it back after app restart from data.variable straight to a text field. This works good.
SET and GET looks too simple. Set item to storage (sorry not on my computer at this moment) ask for 2 things. Key and records I believe.
What is the key? How does this custom ID or name link up to on-device storage just by a key?
What records? The records to store probably but, the key does not suggest how this record corrolate just by one key. I’m assuming if I figure out how to “set item to storage”, I would know “get item from storage”.
Looking for an outline of using SET and GET working, even a flow like what you show with what the formula would look like. UNLESS I am totally missing the picture because my METHOD is from on-device data to on-device data.
Set/get item to storage are not for managing the data resource On-device storage. They are simple but more advanced ways to set something into the device’s storage and then get it. If you can, I would use On-device storage and its flow functions directly, since using set/get item to storage is not as easy, since their use is prone to mistakes.
Simple example of set/get item to storage:
My app has
products that I fetch from a REST API. There are 2000 products.
key used in set/get can be whatever so long as it matches, in this case I would choose “products”.
I would from global canvas app launch event get item from storage with key “products”, if it’s not empty then set the results of get item from storage to the data variable, if that is empty, then do the get of Products from the REST API. After getting them from the REST API, I save them to storage using set item to storage (with key “products” and data being the content of the get request).
Note that it won’t know the schema of what you have set into storage, so you will have to use formulas.