There are situations that all you need for your app to work is a local table to store some data for your app and you do not need the mobile to be connected to the internet all the time.
But, what if the user had to reinstall the app? All data in the local table is lost and there is no option to even back it up before reinstalling the app.
This demo uses the
Email share component to save the data in an email message so that it can be retrieved later.
Of course, you can choose to use
Google Apps Script to automate the email process but this is beyond the scope of this tutorial.
The demo app is a simple single screen app with a DVL showing the content of the local table.
Backupbutton will loop through the rows in the table making a
JSONstring and once done will send this string to a designated email.
Clearbutton will delete all rows in the local table.
Restorebutton will ask the user to paste the JSON received by email in the
Text Inputfield to use it to repopulate the local table again.
- For ease of testing, I have provided a variable with sample data so one can use it to test the restore process.
Converting table rows to JSON string
Send JSON rows to email
Restoring data to local table
Making sure the user pasted the JSON
Verifying the JSON to be valid