Work with the internal files in the app. Copy. KIO4_Terminal extension. "files" and "shared_prefs" directories. Study

Hello friends,

a few months ago I wrote on this topic about TinyDB files:

Now I am going to do a study on the internal files in the application, for this it will use the com.KIO4_Terminal.aix extension that you can find in:
http://kio4.com/appinventor/278C_extension_shell_Archivos.htm

1.- To carry out this study it is convenient that the app is installed (Build). We close it and we open it again.

2.- The application will create an internal file (my_file.txt) and a TinyDB1.
It also contains two files in the assets (texto.txt and imagen.png)

1 Like

  • When we press the "List files" button, we execute the LINUX command
    ls -Ral
    and we obtain a list of the internal files of the app.

R: recursive
a: hidden
l: long format

With block GetAppDirectory, we get:

/data/user/0/appinventor.ai_juan.get_files

Look at the directories:

/data/user/0/appinventor.ai_juan.get_files/files
/data/user/0/appinventor.ai_juan.get_files/shared_prefs

1 Like

Block of extension com.KIO4_Terminal.aix

  • We are going to copy the files from the "assets" directory to the internal "files" directory by pressing the button "Copy files from assets to "files" directory".

  • And then we press the "List files" button again.

Now in the internal directory "files" the assets files have been copied (imagen.png and texto.txt)

1 Like
  • We have copied the "texto.txt" file from the assets to the "files" directory, with CopyAllAssets block,

  • Can we read and modify it from the File component?

  • Yes, with File.ReadFrom (texto.txt)

terminal_archivos5

  • Now we are going to copy the TinyDB1.xml file found in the "shared_prefs" directory into the "files" directory.
    For that we will use the CopyAllTinyDB block.

terminal_archivo6

  • Can we read the TinyDB1.xml file in the "files" directory?

Yes, with File.ReadFrom block:

This may be the only way to track down where files are actually located based upon what we are seeing on the forum over the last few days. Reminds me of some sci fi film (can't remember which) where everything was random/parallel/paradoxical.....