TinyDB. Restore after app reinstall or wipe date

Good day to all!
I have encountered a seemingly simple problem - saving a TinyDB backup and restoring it after reinstalling the application or deleting its data. It seems that I have already gone through the circle of different extensions several times: ETinyDB, MFile, TinyDBx...
Please - tell me how I can implement the ability to periodically save a TinyDB backup to a file and then restore it after reinstalling the application.




When restoring after clearing data - such an error
photo_2025-04-14_21-50-07

Thanks in advance for your help!

You will need SAF to access non media files, which your app does not own

Taifun

1 Like

I would be grateful if you could tell me how to implement this. I am a beginner and I can't figure out such a large number of blocks.

blocks (86)

Use the FilePicker to allow the user to select the file, then use File component to read the file's content. Then give it to ETinyDB

1 Like

thank you, I will try

1 Like

Please tell me where to get FilePicker ?
Here?

image

1 Like

You can do this without extensions or files too.

TinyDB has a block that can dump its contents into a dictionary.

Dropping a dictionary into a sharing component text stream block can feed the contents cross platform to your email or text editor apps as a JSON text string.

Coming back, the AI2 textbox should be able to accept an Android paste of a text copy done from the email client or wherever you saved the JSON text string.

The web component has a block that can decode the JSON text into a dictionary.

There is a for each key and value loop block that can traverse the dictionary.

Loop through the dictionary and reload TinyDB from the dictionary, using the keys as tags, value for value.

1 Like

I saved your message. Thank you very much.

You're not the first to ask for this.

Here's the sharing code:

1 Like

Thank you very much to you and everyone who helps!
Everything worked out.
The preliminary version is in the screenshot below. In the final version for my application, I will format it a little differently, add the date and time to the file name, and add "Share".

1 Like

I suggest you to save the important parameters of each user of the app in its own label of a FireBase data base, so key data can always be retrieved, even if the user changes it's mobile phone, or the device where the app is used.

The user will be able to save their backup file anywhere in order to restore it later.

With FireBase, it can be done in such a way that the restore procedure is automatic.
If the app starts without user data in tinydb, then asks: Are you a new user and want to register, or do you want to recover your previous data?

Thanks, but this is probably the next level for me.
I had a hard time logging in through the FireBase using the user's private key and the device ID . But I implemented it