lets say we want to do a simple app for android and for this app we want some data. Tho开发者_Go百科se data when i test my example on my pc locally i have them in a file with json format. lets say that the app doesnt need an internet connection so we cant send a request to a server somewhere.
Now if i move to the android device ( in my case the titanium emulator ) i dont have a server so i can't fetch my json data file.
So whats the secret ? how am i going to do this work ? how all those native apps work with no server, no database, not a way to fetch an xml or json data file ?
thnx
This page provides examples of three ways to work with local data: http://wiki.appcelerator.org/display/guides/Working+with+Local+Data
- Application Properties
- Filesystem Data
- Local SQLite database
If you specifically want to work with JSON data, this example should be a huge head start for you: http://wiki.appcelerator.org/display/guides/Working+with+Local+Data#WorkingwithLocalData-StoringJSobjectsasJSONinproperties
take a look at the kitchenSink examples, specifically the FileSystem examples
they will demonstrate how to read and write from the local filesystem of the device
filesystem.js in KitchenSink
as i see, i think you want to save some data locally right?
actually for me, i keep some simple information in the Ti.App.yourdata
such as
win.js
..... win.name='your name'; Ti.App.name=win.name;
then you can use Ti.App.name for value of win.name anywhere
another way is use Ti.DB
that's local db
sorry if it's not answer you question :p im beginner too
Check out SculeJS, it's a pure JavaScript NoSQL database system designed for use in Titanium, NodeJS, and web based applications. The project is a rewrite of JSONDB.
精彩评论