Search code examples
javascriptdatabasejsontitanium

JSON parsing a Titanium.App.Properties string


In an app, made with TideSDK; i assign a global variable (shocking I know) to a the JSON parse of a string stored in Titanium.App.Properties:

var workbookArray = JSON.parse(Titanium.App.Properties.getString('workbookArray'));

workbookArray is an array of objects.

And then on the unloading of a page, I assign Titanium.App.Properties string the value of workbookArray, which may have been changed by whoever has used the app:

Titanium.App.Properties.setString('workbookArray', JSON.stringify(workbookArray));

Each time I open the app, however, I'm told that JSON was unable to parse the first code snippet (initializing workbookArray).

Aside from this issue, I don't expect to use the app Properties API for my storage needs in the longterm, I wish i could use indexedDB with titanium. SQL is an option, but is a little messy when it comes to objects. Any other suggestions for a database solution?


Solution

  • Try getList and setList

    http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.App.Properties

    What is stored in the list?