Assets app - limit

Hello.
Can anyone advise?
I want to display about 150 html files in the app via the menu. Can I import those files into app assets?
Each file has about 150 lines.
Won't the app be too big?
And how do I "call" that html to a menu item and then to a screen?

Ondrej

Why do you need 150 HTML files?

A 150 line html file is going to be @ 5.2kB in size, therefore 150 files will be @ 850kB.

These will easily fit inside your app in the Assets, however, such a large number of files may cause file and compilation issues. I say may, it could all work perfectly well

AI2 has a special url for html files in assets:

http://localhost/myfile.html

You set this in the webviewer.GoToUrl block

As an alternative, you could set up a routine to download all the files to your ASD or Shared Storage on first run of the app. The file path would then be, for example if files in the ASD:

file:///storage/emulated/0/Android/data/<packagename>/files/myfile.html

See also how I downloaded multiple files in one go using Taifun's zip extension

2 Likes

Thanks.
Theoretically, I could merge those html files into one file, but I can't imagine how to call them separately in the screen via the menu.
Ondrej

Yes, theoretically you could just have one big html file, and use javascript/html/css (whatever) to display the correct file. You could use the webviewstring to send a value from the app, the javascript would then display the html as specified by the value sent. Something like:

//......
<script>
// hide all divs
var divs = document.getElementsByTagName("div");
for (var i = 0; i < divs.length; i++) {
  divs[i].style.display = 'none';        
}

//show div based upon supplied display number
var displayNo = window.AppInventor.getWebViewString();
document.getElementById(displayNo).style.display = 'block';

</script>
//.....
<body>
<div id=1></div>
<div id=2></div>
<div id=3></div>
</body

This is all you need to download multiple html files to the ASD (in my example only 3):

Here is a test aia:

You can then also copy / move these files from the ASD to one of the Shared folders (/Documents or /Download) - for whatever reason.

And btw, without storage permissions on Android 11+ using one of the File extensions.

1 Like

Yes. You can drag and drop them. It is a slow process (not the dragging, but AI's processing). Sometimes some files don't go into the Media correctly and you have to redo those particular files. Alternatively you can us an unzip tool to explode the aia and enter the html files by adding them there).

Yes. I have an app that uses about 1000 html files that are text only. The size limit is 5mb; I don't know what the number of files limit is but 1000 works for me ; 150 should not be a problem. Why not try, the dragging and drop to import the htmls is easy and should not take long. Experiment. :slight_smile:

You do not need ASD although that could work. Storing in Media, provided you later do not have to modify the files is OK.

As others stated, you will probably need to use the code... server. I have to.

The app's aia takes several minutes to render. You need to be patient. The compiled apk loads fast.

I would like to see and try an aia with 1000 html files in the assets.
I doubt that works.

(I tried it some time ago with 500 small text files with AI2 & Kodular and it didn't work. As far as I remember it worked with 300).

Why? Here is an example

bibleSize

It runs fine in a Samsung Android 11.

1 Like

Did you use http://ai2.appinventor.mit.edu/ or http://code.appinventor.mit.edu/ for this app?

I tested an app with 480 html files in the assets, but it is not possible

  • to build the APK
  • to export the aia

see also here:

As said previously Anke, code.appinventor works fine to build the APK and export the aia; the main server balks and chokes and cannot build an aia or apk.

You have to have faith. “O you of little faith, why did you doubt?” Matthew 14:31 . I did it a few weeks ago. I started to write a tutorial but didn't think anyone would be interested.

Try again and have more patience. :slight_smile:

Where did you say that before?

Does that work on http://ai2.appinventor.mit.edu/ ?
As I said, I doubt that.

[quote="SteveJG, post:9, topic:52314"]
As others stated, you will probably need to use the code... server. I have to.
[/quote] (should have said too instead of to :slight_smile: )

The main server can not handle that many files. :cry: so use code... server and your Project should compile/load. Try it. :slight_smile: Developers have to experiment. I can do it with my htmls.

1 Like

Ah ok, I would have expected the link there. That's easy to overlook.
But good to know that http://code.appinventor.mit.edu/ works with many assets.

1 Like

... and isn't it running on Amazon server?

my understanding is the http://code.appinventor.mit.edu/ runs on the Amazon server. That is the server I used with my Project to compile and create the aia for a Project with larger numbers of htmls. I have no idea what the limit of files might be. My Project has in excess of 1000 of html files. I didn't count exactly how many.

2 Likes