No resource Folder in Android

I just read this piece on the Resources Folder which states
[text]
On Android devices, there is no Resources folder because all resource files reside inside a compressed APK file.

An Android APK is really a zip file. The files in the resource directory are inside the APK file, therefore they are compressed within a zip file (instead of residing in an actual directory). The Lua I/O API such as io.open() is unable to open/extract files inside a zip file, thus it cannot open files within an APK.

With that said, we’ve implemented some special handling on Android. Calling system.pathForFile() on certain file types will cause Corona to automatically extract that file and copy it to an outside directory. It is wasteful on storage space, but it does allows Lua I/O APIs to access certain file types.

system.pathForFile() will auto-extract all file types EXCEPT the following: ? *.html? *.htm? *.3gp? *.m4v? *.mp4? *.png? *.jpg? *.ttf

This means that the above file types cannot be accessed by Lua I/O API. All other files will be automatically extracted when calling system.pathForFile() first.

Workaround:

One way to access one of the above files (e.g., png and jpg) is to rename the file to something like “file.png.txt”. You would typically copy one of these files to the Documents or Temporary directory and rename it back to it’s original name. Just be aware that large files will add to the memory space used by your app.
[/text]

I have never heard of this before… Can any of you guys confirm from which version of Corona, the above applies? I mean I have been using Corona for a year or so, and I never knew about this, but still I haven’t got any error because of this till now… [import]uid: 64174 topic_id: 33620 reply_id: 333620[/import]

I’m not sure how far back this goes, but its been this way for a long time, perhaps going back to the beginning of the Android support because that’s how Android works.

What kind of problem are you running into?
[import]uid: 199310 topic_id: 33620 reply_id: 133660[/import]

No problems so far actually, that’s why I was a bit puzzled…
No worries anyway, I was just wondering…
[import]uid: 64174 topic_id: 33620 reply_id: 133663[/import]

Let me clarify…

All of the files in your Corona project directory, that is, the files you access via the [lua]system.ResourceDirectory[/lua], reside within the “assets” directory within your APK file. However, since APKs are really zip files, these files are not easily accessible via file io functions.

To prove my point, change the extension of your APK file to *.zip and then decompress it. This will reveal the internal structure of an APK. Notice that the files under the “assets” directory are your resource files.
(Also note that zip files don’t actually contain directories. Zip files contain file “entries” whose names may include a directory path which is merely a de facto convention.)

Android provides classes/APIs in Java to access these files within your APK’s assets directory without decompressing the APK, which is what you want if the Android device’s internal storage is low on space. Corona uses these Android APIs in order to access your resource files seamlessly within the APK without decompressing these files… but only for the file extensions mentioned in the documentation that you’ve mentioned above. All other files are extracted, such as audio files, because Corona uses some native C/C++ libraries that require direct file IO access. Ultimately, this is a hack on our part until we can find an alternate solution.

Bottom line, yes, your resource files are there, but they all reside within a zip file. [import]uid: 32256 topic_id: 33620 reply_id: 133746[/import]

I’m not sure how far back this goes, but its been this way for a long time, perhaps going back to the beginning of the Android support because that’s how Android works.

What kind of problem are you running into?
[import]uid: 199310 topic_id: 33620 reply_id: 133660[/import]

No problems so far actually, that’s why I was a bit puzzled…
No worries anyway, I was just wondering…
[import]uid: 64174 topic_id: 33620 reply_id: 133663[/import]

Let me clarify…

All of the files in your Corona project directory, that is, the files you access via the [lua]system.ResourceDirectory[/lua], reside within the “assets” directory within your APK file. However, since APKs are really zip files, these files are not easily accessible via file io functions.

To prove my point, change the extension of your APK file to *.zip and then decompress it. This will reveal the internal structure of an APK. Notice that the files under the “assets” directory are your resource files.
(Also note that zip files don’t actually contain directories. Zip files contain file “entries” whose names may include a directory path which is merely a de facto convention.)

Android provides classes/APIs in Java to access these files within your APK’s assets directory without decompressing the APK, which is what you want if the Android device’s internal storage is low on space. Corona uses these Android APIs in order to access your resource files seamlessly within the APK without decompressing these files… but only for the file extensions mentioned in the documentation that you’ve mentioned above. All other files are extracted, such as audio files, because Corona uses some native C/C++ libraries that require direct file IO access. Ultimately, this is a hack on our part until we can find an alternate solution.

Bottom line, yes, your resource files are there, but they all reside within a zip file. [import]uid: 32256 topic_id: 33620 reply_id: 133746[/import]