Frage

This question is about implementation. I'm building an android application with titanium. There are multiple screens and i take data in each of them. Each screen is a commonJS module

I want to write all the data i take to an sqlite3 database, but i suppose it would be inefficient to write them as i take inputs. Two ways come to my mind as to how to do this.

  1. create an object and pass to each module to hold the data as i take them
  2. create an object in the first module to hold the data and pass each data item to it by firing a custom event.

What i'm asking, is if there's a better approach to this or which of these two would be more efficient.

NB: I don't have a lot of screens, but that could change though. Thanks.

War es hilfreich?

Lösung 2

i think Ti.App.properties set and get string would do fine for you here is example too

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

Thanks

Andere Tipps

Titanium.App.Properties are widely used for Global variable creation.

The following methods will help you to create global variable

  1. setBool : Sets the value of a property as a Boolean data type

  2. setDouble : Sets the value of a property as a double (double-precision, floating point) data type

  3. setInt : Sets the value of a property as an integer data type

  4. setList : Sets the value of a property as an array data type

  5. setObject : Sets the value of a property as an object data type

  6. setString : Sets the value of a property as a string data type

All the above methods will allow user to save corresponding type of data as gloabl. You may retrieve saved values using getBool, getDouble, getInt, getList, getObject, getString methods respectively.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top