Storing Data in Thunkable

  • 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.

mobile phone with app showing stored variables
Stored variables
3 phones pointing to single database
Cloud Storage

Thunkable has several cloud storage options.

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.

stylized A, AmeriCorps logo in navy

ACTIVITY: STORE GAME SCORES

Estimated time: 60 minutes

Update the Quick Quiz Game to Store High Scores

  1. Open the starter project in Thunkable.
  2. Make a copy of the project so you can edit it.
  3. Follow along with the video below to link a Google Sheet to your app to store and update players' high scores.
Open Starter Project

CHALLENGE

Now that you have coded the Quick Quiz game to read, write and update personal high scores, can you:

  1. Read the high scores of all players and find the highest score of all players
  2. 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.

strings of numbers
What data will you need to store for your app?
Does it need to be stored
in the app,
on the user's mobile device,
or in the cloud for sharing
Is it a combination of storage requirements for your app? You can use all 3 options!

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.