How can I include the files inside the app and how do I write the path when I open them?

World is wide and there are so many powers!!!
I am thankful to you every day.

I want to include (attach, not appendtofile) the txt files inside the app.
For example,

The “folder1” has 3 txt files(1.txt, 2.txt, 3.txt).
The “folder2” also has 3 txt files(1.txt, 2.txt, 3.txt).
The “folder3” also has 3 txt files(1.txt, 2.txt, 3.txt).

Each folder has the txt files of same name but their contents are different.
All txt files have been made already and I want that users can’t see them.

How can I include them inside the app?
And how do I write the path when I open them?

Yes you can do this, but not in the Designer or Blocks screen.

  • Create your app
  • Create your files and folders on your computer
  • Add at least one asset to the media folder, e.g. an image for your app icon
  • Export your project as an aia file
  • Open your aia file with an unzip program
  • open the assets folder
  • insert your folders with files in them
  • Close the aia
  • Rename the aia to something different to the one on your AI2
  • Import your newly named aia project to AI2
  • All the files will show in the Media area, even though they may have the same names

To access a file in a folder on your assets (if a text file use the file component)

File read
//folder1/1.txt
or
//folder2/3.txt

This works in companion, needs testing when compiled

1 Like

Thank you for your reply.
That way is sufficient for me.

I tested this method making sub-folders just ago.
It is impossible making a sub-folder.

My phone shows a massage in Korean, so I don’t know that massage in English exactly,
Maybe it is “The app has not been installed”

Is the problem when the app is compiled ?

1 Like

Yes.
When I put the txt files under assets folder, it is Ok.
When I make a sub-folder under assets folder, and I put the txt files under sub-folders, it is not Ok.

P.S. In above sentence, “under” is correct, or “inside” is correct?
I just wonder as a Korean having poor English.
It is too difficult to use prepositions.

But why the files have to be with same names?

1 Like

You are adding the folders in the aia file and not on your companion device?

1 Like

Just tested with compiled app and it doesn’t work for me either :frowning:

You may have to put a prefix to your files e.g. F1File1.txt F2File1.txt and rework your blocks to accommodate this.

Unless someone else can provide a solution to this ?

1 Like

As your previous answer
I did
unzip aia file -> copy and paste txt files to assets folder -> zip all files –> rename zip to aia

It can be the way to put a prefix to filename.
Then is there any restriction to put files in assets folder, for example; quantity, type and size of files?

Exactly how many, how big, what type ?

The main AI2 server can produce apk files of no more than 10mb (an empty apk = 3.5mb)

The code ai2 server can produce larger apks

How many depends on what is manageable and practical for you given they are all in the same folder.
A couple of hundred maybe, but not thousands - assets is the wrong place for them.

You can also create an application specific directory once the app has loaded, and download files from an online source you have setup (e.g. file server / google drive). This directory also cannot be seen by the app user on their device, outside of the app.

1 Like

I have 120 txt files, each file size is under 30kB.
30kB * 120 < 4MB

Each txt file has 100 lists(the length of file is 100)
Each list has a mp3 file matched it. And the size of each mp3 file is about 40kB.
40kB * 12,000 < 500MB

It would be good using the assets folder to save txt files, and a “specific directory” to save mp3 files.

Then please teach me how to manage to make a “specific directory”, and how to describe the path when I play mp3 files.

You should be OK with your text files as assets, but as you show, your mp3 files would need to be downloaded on first use (or as needed as they are not that big). You should decide whether they “have” to be on the app (big download on first use), or whether you can store them somewhere online for use as and when they are needed - or somewhere in between.

Easiest approach is to use Taifun’s File Extension

and the FileByFile method for downloading on first use

1 Like

Oh it’s too difficult.
I need more time to understand it.
As FileByFile isn’t way I want, I put aside it.
I should study more Taifun’s File Extension.