2013-08-21 36 views

回答

4

简单的例子展示使用Titanium App Properties module

我设置在service.js service_running布尔值并在app.js验证

app.js

var isRunning = Ti.App.Properties.getBool("service_running", false); 

if (isRunning) 
    Ti.API.info('service is running'); 
else 
    Ti.API.info('service is not running'); 

service.js

Ti.App.Properties.setBool("service_running", true); 
2

应用程序属性模块用于存储属性/值对中的应用程序相关数据,这些属性/值对在应用程序会话和设备电源周期之外存在。

实例

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')); 

More.