How do you save and load file txt into tinydb with different tags?

Good evening everyone, like many of you, I am a self-taught individual who enjoys this curious way of programming. However, it seems that I have reached my limit, and I am seeking help in this community that knows infinitely more than I do. Let me explain; with all the puzzles of App Inventor, tutorials, and various online searches, I have managed to make the logic work to create a functioning password manager. Now, I wanted to export all the passwords stored on TinyDB to the smartphone in the form of a file that can then be reloaded by the app. The TinyDB stores in the app three tags named "Account," "Username," and "Password." Each of these tags stores text and numbers. I hope to receive some answers to complete the logic of my puzzle, and I thank you in advance for your time.

The Perfect Solution

"Thank you for the prompt response. Theoretically, your suggestion is undoubtedly perfect. However, translating it into a puzzle for me is another matter, and unfortunately still not feasible. I am trying to attach the entire AIA file composed of 5 functioning screens, and perhaps you could give me a suggestion on how to build the last two blocks for saving/loading the txt file on the mobile device. At the beginning of screen 5, there is a block with instructions for saving the data in the mobile device's memory extracted from the three different tags of TinyDB, but I can't figure out how to do the reverse. I know that the app seems like a confused puzzle and a Frankenstein-like construct, but it works. Thanks again for the time dedicated to me."
ImaPassword_Kopie (1).aia (521.7 KB)

If you use the suggested extension above, set your three tags into the same namespace, not used by any other tags. Then you can export/import the data using the extension.

Good morning, thank you for the suggestion, you gave me a hint on how to do it and i will soon try It and will let you know.

Hi everyone, thanks to Tmai2's suggestion I was able to create the following two blocks, but unfortunately I'm stuck and they don't work. Could you please give me some other pointers?

Please temporarily set the language to English so that it is easier for us to help you.

Ok sorry me for the wrang language .

1 Like

My guess is that you have not set the namespace to "Backupfile" and you have not set the filename correctly.

Ok thanks again for your guess i will try again.

Good evening, unfortunately I am still stuck. With the above block I can save the data directly on the phone but I cannot retrieve it when I want to load it into the application. Any suggestions on how to do it?

This isnt the way to load the backup file, you need to provide a full actual valid path of the file that will be returned by the FilePicker, check those green property blocks from where you get the path which you'll give to the "LoadFile" block.

Thanks again for your guess i will try again.

Good evening, everyone!

I've finally achieved success! With the first block, I can now save a file named "file.txt" containing the three different tags on the mobile device. The second block successfully loads the saved data.

However, I'm facing a challenge: even after loading the data, I need to manually refresh the companion screen using MIT App Inventor to see the updated information reflected in the list.

Do you have any suggestions on how to automatically update the list upon data loading, eliminating the need for manual refresh?

Ok, I managed to solve the problem with some tricks by calling another screen in the program. This way, you avoid manually refreshing the complementary screen using MIT App Inventor to see the updated information reflected in the list.

I am asking the community for one last bit of help to complete my program. Does anyone know how to instruct this block, which I am attaching, to save the BackUp.txt file to the Download folder of the main memory of a mobile phone without an SD card?


Try changing App to Shared and /BackUp.txt to /Download/BackUp.txt.

Note this is an insecure location to store sensitive data!

Thanks again for the suggestion on how to save the txt file, and especially for the advice regarding data security.


Thanks again for your suggestion, but it seems that simply "saving" the contents of the TinyDb to a text file and then storing it on my phone has become an unsolvable problem for me. Let me explain:

With the two blocks I attached, I am able to save a text file called BackUp.txt on my phone. But the strange thing is that when I open the file picker on my phone and wait for the selection of the BackUp.txt file, I can click on any file and the application still loads the BackUp.txt file. Maybe I'm not explaining myself well. I mean that no matter which file I choose after pressing the filePicker button, the application automatically opens the BackUp.txt file ???
I suppose this problem prevents me from loading previous BackUp.txt files with the application. Thanks again for your time and suggestions.

Here is a simple example aia project that uses the etinydb extension. I am still conerned that you may not be doing things correctly?
etinydbTestExtn.aia (13.7 KB)

Can I ask why it is you need to copy this file to shared storage, and then what you intend to do with it once it is there ?