0

I am new on titanium and iPhone development, i want to know how to store value of variable in share preference and get that value on another js?

Sajid
  • 320
  • 3
  • 20

2 Answers2

4

Simple example demonstrating use of Titanium App Properties module

I am setting a Boolean value for service_running in service.js and validating in 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');

In service.js

Ti.App.Properties.setBool("service_running", true);
Amith
  • 1,424
  • 1
  • 10
  • 22
2

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

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

More.

Maulik
  • 19,348
  • 14
  • 82
  • 137