Type Constant Library system.* Revision 2019.3470 Keywords system directory, ResourceDirectory See also system.pathForFile() system.ApplicationSupportDirectory system.CachesDirectory system.DocumentsDirectory system.TemporaryDirectory
Used with system.pathForFile() to create a path for retrieving files where all the application assets exist, for example image and sound files. This is often called the "app bundle."
This property can also be used with other APIs requesting
baseDir as a parameter, for example display.newImageRect(). The resource directory is generally the default directory if no other directory is specified.
You should not create, modify, or add files to this directory. Doing so will prevent the device from verifying the integrity of your application; in some cases the device will treat your application as malware and refuse to launch it.
In the Corona Simulator, this will be in a sandboxed folder on a
/tmp directories, the resource directory is not viewable via
To restate what was mentioned above:
system.ResourceDirectory is where your
main.lua file and generally all of your asset (resource) files are stored. For security reasons, this directory is
File access in Corona is based on the underlining operating system which varies by platform. On iOS devices, you can access files in all of the directories described above. On Android, however, there is no literal
system.ResourceDirectory because all resource files reside inside a compressed
Corona allows direct loading of images and audio files using the appropriate APIs, but it has limited access to resource files on Android using the file I/O APIs. Specifically, the following types can not be read from the resources directory:
Because of this limitation, if you have files of these types bundled in the core directory that you need to copy to another directory, you must change the file name so it can be accessed by the file I/O APIs. For example, if you want to move
cat.png from the resource directory to the documents directory, it must be renamed
cat.png.txt to be copied. See here for details.
-- Get path for file "data.txt" in the resource directory local path = system.pathForFile( "data.txt", system.ResourceDirectory ) -- Open the file from the path local fh = io.open( path, "r" ) if fh then -- File exists; read its contents into a string local contents = fh:read( "*a" ) print( "Contents of " .. path .. "\n" .. contents ) end io.close( fh )