System/OS Libraries

This guide summarizes the Corona system and os libraries. Collectively, the following calls are used to gather system information and control system functions — get device information, enable multitouch, control the idle time, accelerometer, GPS, etc. — and deal with system time, date, and other OS-related information.

System Library

API Description
system.getInfo() Returns information about the system on which the application is running.
system.openURL() Opens a web page in the device browser, creates an email, calls a phone number, or opens a file.
system.canOpenURL() Returns a boolean value confirming whether a URL can be opened via system.openURL().
system.pathForFile() Generates an absolute path using system-defined directories as the base. See Reading and Writing Files for more information.
system.CachesDirectory Used with system.pathForFile() to create a path for storing and retrieving files that are available across application launches.
system.DocumentsDirectory Used with system.pathForFile() to create a path for storing and retrieving files that need to persist between application sessions.
system.ResourceDirectory Used with system.pathForFile() to create a path for retrieving files where all the application assets exist.
system.TemporaryDirectory Used with system.pathForFile() to create a path for storing and retrieving files that only need to persist while the application is running.
system.getPreference() Returns a system preference value (ui or locale) as a string.
system.getInputDevices() Returns an array of InputDevice devices that are currently connected to the system, such as a touchscreen, keyboard, mouse, joystick, etc.
system.getTimer() Returns the time in milliseconds since application launch.
system.orientation Returns a string identifying the orientation of the device.
system.setTapDelay() Sets the delay time between when a tap is detected and when the tap event is delivered.
system.activate() Activates a system-level feature such as multitouch.
system.deactivate() Deactivates a system-level feature activated by system.activate().
system.scheduleNotification() Schedules a local notification event to be delivered at a future time.
system.cancelNotification() Removes the specified notification from the scheduler, status bar, or notification center.
system.setIdleTimer() Controls whether the system idle timer is enabled (automatic screen dim and sleep).
system.getIdleTimer() Determines whether the system idle timer is enabled.
system.setLocationAccuracy() Sets the desired accuracy of location (GPS) events to distance in meters.
system.setLocationThreshold() Sets the distance in meters between each location (GPS) event.
system.setAccelerometerInterval() Sets the frequency of accelerometer events.
system.setGyroscopeInterval() Sets the frequency of gyroscope events in Hertz.
system.hasEventSource() Returns whether the system delivers events corresponding to eventName.
system.vibrate() Vibrates the phone. On the Corona Simulator, this triggers a system beep.

OS Library

API Description
os.clock() Returns an approximation of the amount in seconds of CPU time used by the program.
os.date() Returns a formatted string or a table containing date and time.
os.time() Returns the current time in seconds from 1970, or the date and time specified by a table.
os.difftime() Returns the number of seconds from time "t1" to time "t2".
os.execute() Passes a string to the OS for execution and returns a system-dependent status code.
os.exit() Calls the C function exit() to terminate the host program.
os.remove() Deletes a file or directory in the documents or temporary directory.
os.rename() Renames a file or directory in the documents or temporary directory.