Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Titanium.App.Properties.getString doesn't return default on Android

SDK 1.6, Titanium 1.2.1, Android

var defaultZipcode = Titanium.App.Properties.getString("defaultZipcode", "20500");

after this, 'defaultZipcode' is null, not "20500"

Am I missing something?

— asked November 16th 2010 by Richard Brents
  • getstring
0 Comments

1 Answer

  • Accepted Answer

    Check your code to see if anywhere you may have set defaultZipcode to an empty string. If so, the getString() method will return that instead of the default. One way to check:

    if ( Ti.App.Properties.hasProperty( "defaultZipcode" ) {
        Ti.Api.info( 'Removing previous default zipcode property' );
        Ti.App.Prooperties.removeProperty( "defaultZipcode" );
    }
    Ti.Api.info( Ti.App.Properties.getString( "defaultZipcode", "20500" ));
    
    — answered November 16th 2010 by Doug Handy
    permalink
    1 Comment
    • <Forehead Slap />
      That was it - a previous null value … I guess I was looking too hard (and pulling too much hair out <G>)

      Thanks!

      — commented November 16th 2010 by Richard Brents
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.