org.appcelerator.titanium
Class TiProperties

java.lang.Object
  extended by org.appcelerator.titanium.TiProperties

public class TiProperties
extends Object

API for accessing, storing, and modifying application properties that are exposed via Ti.App.Properties.


Method Summary
 boolean getBool(String key, boolean def)
          Returns the mapping of a specified key, as a Boolean.
 double getDouble(String key, double def)
          Returns the mapping of a specified key as a Double.
 int getInt(String key, int def)
          Returns the mapping of a specified key as an Integer.
 String[] getList(String key, String[] def)
          Returns the mapping of a specified key as a String array.
 String getString(String key, String def)
          Returns the mapping of a specified key, in String format.
 boolean hasListProperty(String key)
           
 boolean hasProperty(String key)
          Returns whether key exists in preferences.
 String[] listProperties()
          Returns an array of keys whose values are lists.
 void removeProperty(String key)
          Removes the key from preferences if it exists.
 void setBool(String key, boolean value)
          Maps the specified key with a boolean value.
 void setDouble(String key, double value)
          Maps the specified key with a double value.
 void setInt(String key, int value)
          Maps the specified key with an int value.
 void setList(String key, String[] value)
          Maps the specified key with String[] value.
 void setString(String key, String value)
          Maps the specified key with a String value.
 

Method Detail

getString

public String getString(String key,
                        String def)
Returns the mapping of a specified key, in String format. If key does not exist, returns the default value.

Parameters:
key - the lookup key.
def - the default value.
Returns:
mapping of key, or default value.

setString

public void setString(String key,
                      String value)
Maps the specified key with a String value. If value is null, existing key will be removed from preferences. Otherwise, its value will be overwritten.

Parameters:
key - the key to set.
value - the value to set.

getInt

public int getInt(String key,
                  int def)
Returns the mapping of a specified key as an Integer. If key does not exist, returns the default value.

Parameters:
key - the lookup key.
def - the default value.
Returns:
mapping of key, or default value.

setInt

public void setInt(String key,
                   int value)
Maps the specified key with an int value. If key exists, its value will be overwritten.

Parameters:
key - the key to set.
value - the value to set.

getDouble

public double getDouble(String key,
                        double def)
Returns the mapping of a specified key as a Double. If key does not exist, returns the default value.

Parameters:
key - the lookup key.
def - the default value.
Returns:
mapping of key, or default value.

setDouble

public void setDouble(String key,
                      double value)
Maps the specified key with a double value. If key exists, its value will be overwritten.

Parameters:
key - the key to set.
value - the value to set.

getBool

public boolean getBool(String key,
                       boolean def)
Returns the mapping of a specified key, as a Boolean. If key does not exist, returns the default value.

Parameters:
key - the lookup key.
def - the default value.
Returns:
mapping of key, or default value.

setBool

public void setBool(String key,
                    boolean value)
Maps the specified key with a boolean value. If key exists, its value will be overwritten.

Parameters:
key - the key to set.
value - the value to set.

getList

public String[] getList(String key,
                        String[] def)
Returns the mapping of a specified key as a String array. If key does not exist, returns the default value.

Parameters:
key - the lookup key.
def - the default value.
Returns:
mapping of key, or default value.

setList

public void setList(String key,
                    String[] value)
Maps the specified key with String[] value. Also maps 'key.length' to 'value.length'. If key exists, its value will be overwritten.

Parameters:
key - the key to set.
value - the value to set.

hasListProperty

public boolean hasListProperty(String key)
Parameters:
key - the lookup list key.
Returns:
true if the list property exists in preferences

hasProperty

public boolean hasProperty(String key)
Returns whether key exists in preferences.

Parameters:
key - the lookup key.
Returns:
true if key exists in preferences.

listProperties

public String[] listProperties()
Returns an array of keys whose values are lists.

Returns:
an array of keys.

removeProperty

public void removeProperty(String key)
Removes the key from preferences if it exists.

Parameters:
key - the key to remove.


Copyright © 2010-2012 Appcelerator, Inc. Licensed under the Apache License 2.0