Backup local database idea. Your thoughts?

I just had some success with creating a simple method of backing up a local database. More work is needed and this would require a web service to actually store the data someplace, but I can build that stuff. My concern was how to get the data out of my Thunkable app and I think this will work. This very simple block arrangement will cycle through a local database and create a list from all the contents. Then convert that list to JSON which can be sent to wonderland. I would love your thoughts on this. I’m sure I’m not the first person doing this so I’m eager to learn from others.


2 Likes

That looks like a straightforward way to store the data and makes use of Thunkable’s own JSON parsing so it’s pretty block efficient.

If you need a suggestion for where on the cloud to store it, you might consider using Firebase - have your users log in so each one has their own data storage, then store that JSON in Firebase under each user’s ID.

1 Like

Local Data in Thunkable is formatted as table so if I want to take a copy I would connect Google sheet and go through the records in the Local Data to append them into my Google sheet.

1 Like

I agree and that would be great for just me but that won’t work for others because I don’t see any way for you to create a connection to a personal Google Sheet on the fly correct? The issue I’m trying to solve is that when a new release of my app comes out the users can back up their data. I need this data to be local to the phone and not in the cloud. This is for mountain bikers and we do not always have access to internet where we are setting up out bikes. Is there a way for a user to create their own Google Sheet connection? That would be cool if they could and would save me from having to create any services. Please share :slight_smile:

2 Likes

That might be an option. It might also be a few more steps then my mountain biker folks will take. I was going to try this approach.

  • Have a button that says “SMS your Backup ID” and a text box for the phone number (could do the same thing with email so just not sure)
  • When ID arrives you copy it.
  • Another text box for you to paste that Id and another button that says “Back up”
    When you push the back up button it pushes the data to an online database using that ID to flag the data just for that user.

Now I have a way to store data for specific users pretty easily and they can restore the data by simply passing that id back up to another service.

Thoughts?

In this case, you can store the data as a stored variable in the phone but it will only be accessed by the app.

Alternatively, allow the user to store the file as .txt local in the phone. You can use a variation of my app Export to vCard to accomplish it.

Here is a link to Export to vCard

1 Like

Oh that sounds promising! I didn’t know we could read flat files off the phone’s storage. Thank you!

1 Like

I like that vCard example. So you’re using a service you created up on GitHub to create the card file and since you are trying to open it as a link the default open for the file type kicks in. Very cool indeed!

1 Like

Now, is it possible for an app to read from that file? I thought I saw an option in the list object to create a list from a csv so I’m thinking yes.

1 Like

I chose to place it in GitHub but you can have it anywhere including the phone storage itself as long as you have the path to run it.

You van have it as part of your assets if you wish.

But how would I now read this file and restore the database from it?

1 Like

The web API will read the file and if you store it originally as JSON then you will be able to work with it just like any response from API calls.

Understood. So some web services will be needed to pull this off.

  • Create a service to build a JSON file that can be stored locally to the phone
  • Create a service that can take the local file, read it and send back the data for the web api to use and create a database from.

Would you mind outlining the process please on how this would work? I don’t really need the code but more the process because I’m still not sure what can be done.

You might have a look at this project for the second part.

1 Like

This is more complicated than needed. Just add Web API component and pass the file path to it. the green response would be the content of the text file.

1 Like

Cool, thanks @muneer! I learned something new today. :slight_smile:

1 Like