Titanium.App.Properties

Submodule of Titanium.App.
Platform Since
Android 0.5
iPhone 0.5
iPad 0.5
Mobile Web 1.8

Summary

The App Properties module is used for storing application-related data in property/value pairs that persist beyond application sessions and device power cycles.

Code Examples

Store a property

Store a string property.

Ti.App.Properties.setString('givenName', 'Paul');
Ti.API.info('The value of the givenName property is: ' + Ti.App.Properties.getString('givenName'));

Enumerate over saved properties

Output all saved properties to the console.

var props = Ti.App.Properties.listProperties();
 
for (var i=0, ilen=props.length; i<ilen; i++){
    var value = Ti.App.Properties.getString(props[i]);
    Ti.API.info(props[i] + ' = ' + value);
}

Methods

Name Summary
addEventListener

Adds the specified callback as an event listener for the named event.

fireEvent

Fires a synthesized event to any registered listeners.

getBool

Returns the value of a property as a boolean data type.

getDouble

Returns the value of a property as a double (double-precision, floating point) data type.

getInt

Returns the value of a property as an integer data type.

getList

Returns the value of a property as an array data type.

getString

Returns the value of a property as a string data type.

hasProperty

Indicates whether a property exists.

listProperties

Returns an array of property names.

removeEventListener

Removes the specified callback as an event listener for the named event.

removeProperty

Removes a property if it exists, or does nothing otherwise.

setBool

Sets the value of a property as a boolean data type. The property will be created if it does not exist.

setDouble

Sets the value of a property as a double (double-precision, floating point) data type. The property will be created if it does not exist.

setInt

Sets the value of a property as an integer data type. The property will be created if it does not exist.

setList

Sets the value of a property as an array data type. The property will be created if it does not exist.

setString

Sets the value of a property as a string data type. The property will be created if it does not exist.

Properties

This type has no properties.

Events

This type has no events.