The top-level Database
module, used for creating and accessing the
in-application SQLite database.
Constant for requesting a column's value returned in double form.
Constant for requesting a column's value returned in double form.
Constant for requesting a column's value returned in float form.
Constant for requesting a column's value returned in float form.
Constant for requesting a column's value returned in integer form.
Constant for requesting a column's value returned in integer form.
Constant for requesting a column's value returned in string form.
Constant for requesting a column's value returned in string form.
The name of the API that this proxy corresponds to.
The name of the API that this proxy corresponds to.
The value of this property is the fully qualified name of the API. For example, Button
returns Ti.UI.Button
.
Indicates if the proxy will bubble an event to its parent.
Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window. Other common parents are table sections to their rows, table views to their sections, and scrollable views to their views. Set this property to false to disable the bubbling to the proxy's parent.
Default: true
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.
Adds the specified callback as an event listener for the named event.
Name of the event.
Callback function to invoke when the event is fired.
Applies the properties to the proxy.
Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.
A dictionary of properties to apply.
Fires a synthesized event to any registered listeners.
Name of the event.
A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.
Installs an SQLite database to device's internal storage.
Copies an SQLite database file to the device's internal storage (only) and creates a persistent name that is available for the lifetime of the app. On Android, if the source file does not exist, an empty database is created.
Returns a reference to the opened database. If the destination file already exists, behaves as open.
This method is primarily used for iOS.
With Android, as there is often minimal internal storage available, install
may only be appropriate for small databases or for prototyping. When database
files are to be stored on external storage (for example, SD Card), a combination of
Titanium.Filesystem and open is required.
With Titanium 1.8.0.1 on iOS, the default database location changed in accordance
with Apple's guidelines. If a database file already exists in the old
location, install
will automatically move it to the new location
rather than copying the file from the path provided in the first
argument.
Files stored in the Private Documents
directory on iOS5 will be
automatically backed up to iCloud and removed from the device in low
storage situations. See
How do I prevent files from being backed up to iCloud and iTunes?
for details. To prevent this for database files, use the Titanium.Database.DB.file
object with the Titanium.Filesystem.File.setRemoteBackup method.
Always close the database after use.
A database, with a filename of mydb1
and located in the same directory as the
the running script, is installed.
var db1 = Ti.Database.install('mydb1', 'mydb1Installed');
The file is copied to the default database location with a file
extension of sql
.
On simulator
/Users/user_name/Library/Application Support/iPhone Simulator/ios_version/Applications/apple_app_id/Library/Private Documents/mydb1Installed.sql
(Titanium 1.8.0.1)/Users/user_name/Library/Application Support/iPhone Simulator/ios_version/Applications/apple_app_id/Library/Application Support/database/mydb1Installed.sql
(earlier versions)On device
/Applications/apple_app_id/Library/Private Documents/mydb1Installed.sql
(Titanium 1.8.0.1)/Applications/apple_app_id/Library/Application Support/database/mydb1Installed.sql
(earlier versions)To prevent the database file being automatically backed up to iCloud, use setRemoteBackup
.
db1.file.setRemoteBackup(false);
A database, with a filename of mydb1
and located in the same directory as the
the running script, is installed.
var db1 = Ti.Database.install('mydb1', 'mydb1Installed');
Unlike on iOS, no file extension is added. The file is opened in the following default database location, on both emulator and device.
file:///data/data/appID/databases/mydb1Installed
The device is checked for the presence of external storage and a
database, with a filename of mydb2
and located in the same directory as the
the running script, is installed.
if (Ti.Platform.name === 'android' && Ti.Filesystem.isExternalStoragePresent()) {
var db2 = Ti.Database.install('mydb2', Ti.Filesystem.externalStorageDirectory + 'path' + Ti.Filesystem.separator + 'to' + Ti.Filesystem.separator + 'mydb2Installed');
}
Unlike on iOS, no file extension is added. The file is copied to the absolute path provided.
file:///sdcard/path/to/mydb2Installed
Path and filename of the database file to copy to internal storage. File location is relative to the script's context unless an absolute path, such as one constructed with a Titanium.Filesystem constant, is used.
Destination filename or absolute path, which will subsequently be passed to open.
Opens an SQLite database.
Opens an SQLite database and returns a reference to it. If the database does not exist, creates an empty database file and returns a reference to this opened database.
With Titanium 1.8.0.1 on iOS, the default database location changed in accordance
with Apple's guidelines. If a database file already exists in the old
location, open
will automatically move it to the new location.
Always close the database after use.
A database, with a persistant name of mydb1Installed
and located in the
default database location on internal storage, is opened.
var db = Ti.Database.open('mydb1Installed');
A file extension of sql
is added, and the file is opened from the
following location.
On simulator
/Users/<user name>/Library/Application Support/iPhone Simulator/<iOS version>/Applications/<apple app id>/Library/Private Documents/mydb1Installed.sql
(Titanium 1.8.0.1)/Users/<user name>/Library/Application Support/iPhone Simulator/<iOS version>/Applications/<apple app id>/Library/Application Support/database/mydb1Installed.sql
(earlier versions)On device
/Applications/<apple app id>/Library/Private Documents/mydb1Installed.sql
(Titanium 1.8.0.1)/Applications/<apple app id>/Library/Application Support/database/mydb1Installed.sql
(earlier versions)A database, with a persistant name of mydb1Installed
and located in the
default database location on internal storage, is opened.
var db1 = Ti.Database.open('mydb1Installed');
Unlike on iOS, no file extension is added. The file is opened in the following location.
file:///data/data/appID/databases/mydb1Installed
A database, with a filename of mydb2Installed
and located at the
absolute path provided, is opened.
if (Ti.Platform.name === 'android' && Ti.Filesystem.isExternalStoragePresent()) {
var db2 = Ti.Database.open(Ti.Filesystem.externalStorageDirectory + 'path' + Ti.Filesystem.separator + 'to' + Ti.Filesystem.separator + 'mydb2Installed');
}
Unlike on iOS, no file extension is added. The file is copied to the absolute path, as follows.
file:///sdcard/path/to/mydb2Installed
Opens a Database in a shared directory
var suiteDir = Ti.Filesystem.directoryForSuite('group.appc.Sharing');
if (!suiteDir) {
logInApp('Suite Directory not found, check Entitlements.');
return;
}
var path = suiteDir + 'TestDB';
var db = Ti.Database.open(path);
db.close();
The dbname previously passed to install. An absolute path to the file, including one that is constructed with a Titanium.Filesystem constant or Titanium.Filesystem.directoryForSuite method, may be used.
Removes the specified callback as an event listener for the named event.
Multiple listeners can be registered for the same event, so the
callback
parameter is used to determine which listener to remove.
When adding a listener, you must save a reference to the callback function in order to remove the listener later:
var listener = function() { Ti.API.info("Event listener called."); }
window.addEventListener('click', listener);
To remove the listener, pass in a reference to the callback function:
window.removeEventListener('click', listener);
Name of the event.
Callback function to remove. Must be the same function passed to addEventListener
.
Sets the value of the bubbleParent property.
New value for the property.
Sets the value of the lifecycleContainer property.
New value for the property.