- Learn how to store data on a mobile device to access from a mobile app
- Learn of different options for storing and accessing data in the cloud to share data between app users
These are the activities for this lesson:
STORING LONG TERM DATA
In the last unit, you learned how to use variables and lists to store information in your app.
When the app is closed, all variables stored in the app’s memory are wiped away.
There are times, though that you might want keep track of information between runs of the app. There are two types of long term storage:
Local Storage
Store information on the mobile device to be retrieved each time the app runs.
For example, a user address or high game score.
Cloud Storage
Store information on the web (cloud) so all app users can access the information.
For example, game leaderboard or chat messages.
LOCAL STORAGE
Once the user closes an app, the values of all app variables get erased from the device’s memory.
If you want to store data for the app between runs, you will use stored variables.
Stored variables can be used to store a user’s personal information that does not need to be shared.
For example, the user wants to enter their name, age, address once, not every time they use the app. Another example is tracking something like healthy habits over time. Stored variables are the solution.
Stored variables work just like app variables. Just select stored from the dropdown menu in the initialize block.
With stored variables, there is no initialize value to set it to. The value of the variable will be null, or empty, until it is used in the app, so be careful using it!
You get and set the value of stored variables just like you would an app variable.
CLOUD STORAGE
Cloud Storage allows any user of the app to access and share data. Multiple app users can store and retrieve data found in a database, which is simply a collection of data stored electronically.
Have you ever shared a picture or video on Instagram or TikTok? Apps like these use cloud storage. When your friend uploads and shares a picture, your phone checks the web database for new photos, and then you see it in your feed.
Thunkable has several cloud storage options.
Cloud variables work just like app and stored variables, except the data is stored in the cloud. Select cloud from the dropdown when you initialize the variable.
Thunkable cloud variables are saved to a Thunkable Firebase database in the cloud. Note that you are sharing this database with other Thunkable coders, so it is recommended you make your own Firebase account if you choose this option.
Thunkable lets you use Airtable, Google Sheets, and Webflow platforms to store app cloud data. You can set up tables in any of these platforms, then link them to your Thunkable app.
You attach a data source to your app in the Designer by clicking the database icon on the left. Note that create your own table is local storage, not cloud storage.
There are many blocks available to allow the app to get data, add, update, and delete data.
Mentor Tip
Best practices: Always store a backup of your data somewhere! It’s very easy to delete or accidentally change your data, so make sure to store an extra copy somewhere safe!
Guiding Questions to ask students: Where do you think cloud data is stored? You upload it to a website like google, youtube, tiktok etc but where is it stored after that? Where is the cloud? Companies like Google have HUGE buildings with computers just to store stuff in the cloud. So the joke is: “It’s not stored on the cloud, just someone else’s computer”. Amazon’s data storage:
Mentor tips are provided by support from AmeriCorps.
ACTIVITY: STORE GAME SCORES
Update the Quick Quiz Game to Store High Scores
- Open the starter project in Thunkable.
- Make a copy of the project so you can edit it.
- Follow along with the video below to link a Google Sheet to your app to store and update players' high scores.
CHALLENGE
Now that you have coded the Quick Quiz game to read, write and update personal high scores, can you:
- Read the high scores of all players and find the highest score of all players
- Report that information to the user
- using a label
- or add it to the Alert message
REFLECTION
As you start to code your own app for your project, consider these questions.
in the app,
on the user's mobile device,
or in the cloud for sharing
REVIEW OF KEY TERMS
- Database – an organized collection of information
- Cloud Storage – information that is stored on the web so that any device connected to the internet can access it
ADDITIONAL RESOURCES
Here are more documents and tutorials for exploring cloud storage in an app.
- Make a Login and Posting App that uses Firebase and Sign-In, Google Sheets, and Cloudinary to save and share images in the cloud
- Make a Video Posting app
- Build an App that uses a Google Sheet
- Add the Numbers in a Google Sheet