where to store my data in appcelerator? - titanium

lets say we want to do a simple app for android and for this app we want some data. Those 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.

Related

Storing large data in react native for offline usage

For our app we need the app the work offline 100% with the most recent data.
Normally the app uses a symfony api platform API to fetch data paginated server side.
But when someone is using the app in a area without Internet he still need to be able to access all data to make a new job and que it for when he is online.
So our tough is to make a json that has all the data and send it to the phone when the phone has connection.
When the phone is using the app live, it will use pagination from server and fetch data.
And when offline it will use the local downloaded data file.
Problem is the data is large, so storing it is the problem.
We are now using redux persist and we see so many people have problems with crashes and mobile ram.
We also thought of using sqlite or just async to store a json file, or download a sqlite file from the app.
How do you guys feel about this
You can use react-native-local-mongodb. This can help you store a json database on your phone.
Other option is to have react-native-sqlite-storage in case your database has to be relational and requires table.
You will have to sync this local copy with the server once this user is online. This too can be done if you have the timestamp saved of the last sync. So after that, you ll just have to sync the data created after that timestamp.
However, I had also implemented react redux persist and it didnt crash. I suppose, the reason for crash must me something else.

WebService IOS design optimization

Im using a web service to populate a tableview, but the data in my web database changes very rarely, and i don't need to always download the same data.
I need to storage the data in the device, and verify if the data on the device is different than the one on the web.
What is the best practice to do that? Parse a JSON object, containing the last version and comparing to the local version and then parsing the data if its needed ?
Is there a way to automate the last version?
If you have control over the web APIs then have a separate api that returns a timestamp for the last web data change and check this. If the date is not newer than the date of last download use the local data. imho.
I personally used local storage for the same situation on iOS and it worked great.
You just need to provide an URL which responds with the last version of the data (maybe a date) and then locally in JavaScript you first check if version online is newer than your local stored one, if it is you redownload data and place it into localstorage, otherwise you just keep old data (and don't download anything at all).
Of course everything must be done through Ajax.

Is it possible to store and retrieve objects created using Objective-C? (in a database, for use in iOS app)

I'm working on an iOS app that creates "location sets" where each row contains a location name and a GeoPoint, and each set has its own name. Each of these sets are stored in an object inside our program (all belonging to the same class). Now we want to give users the capability to create sets and upload them to a database, allowing other users to access and download them to their device.
I've been looking in to back-end solutions for work like this, but pretty much everything I've found so far focuses on relational databases and adding and deleting rows and using SQL-like language to retrieve them. Is there a way to store these objects just as objects (and not unpack the info inside to tables), and then retrieve them? It feels like that would be a much simpler way of going about this.
I'm an absolute beginner when it comes to databases, so forgive me if there's info missing here that you would need to help me out. I'll make sure to keep checking back in case someone asks for more info.
Thanks!
Coredata might be useful for you as its based upon the entity. So you can play multiple things around it by using queries (predicates).
But if you just want to save and retrieve back, then as a simplest solution I would suggest to create array/dictionary with entity data, save that into NSUserDefaults so you can retrieve back same while re-launching the app.
Webservices for iOS development:
raywenderlich
icodeblog
WSDL Webservices
Response data parsing, it would be either JSON or XML:
JSON Parsing
XML Parsing
Hope these links would be helpful for you.
I ended up using Parse's mobile back-end service. That was the type of service I was looking for. I've found other similar services since then, like Applilcasa and StackMob, but we're pretty happy with Parse so far.

Pre loaded database on iPhone?

I developing an app that is read-only. The data has relationships, so I cannot just use a plist or something similar.
Questions:
Should I use Core Data for such a requirement?
If so, how would I enter the data and then release the app with that data?
How would I make it so that the app doesn't need to re-populate a DB every time it loads?
Is there a way to create a Core Data model using sql commands with sqlite (i.e. insert into, etc)?
You may use an SQLite database to accomplish this.
Create the model in your iOS app.
Create and populate the database in a Mac OSX utility command-line app
Copy the sqlite file into your iOS app and link it with some code
Work through these two tutorials, line by line, and afterward you will have a good enough understanding (and code sample) to complete this task in your own app.
Core Data on iOS 5 Tutorial: Getting Started
Core Data on iOS 5 Tutorial: How To Preload and Import Existing Data
In my short experience with the iPhone, you have two options.
Write a data import function and run it on the first application launch.
Use solution 1, but build the initial sqllite file in the simulator, and then on first application launch, copy it into the app's documents directory.
From past experience, option 2 is much quicker for user experience, and the preferred solution.
You can write a utility project that imports the app's data model and use throwaway code n that project to populate the Core Data DB. Once the DB is populated, simply copy the actual file to the app project's resources folder and then when you set up your persistent store, use NSBundle to return the path to the DB file within the built app.
And you're done.

Remote Backup User Data on iPhone

I wrote a few iPhone apps using Core Data for persistent storage. Everything is working great but I would like to add the ability for users to back up their data to a PC (via WiFi to a PC app) or to a web server.
This is new to me and I can't seem to figure out where to begin researching the problem. I don't want to overcomplicate the issue if there is an easy way to implement this.
Is anyone familiar enough with what I am looking to do to point me in the right direction or give me a high level overview of what I should be considering?
The data is all text and would be perfectly stored in .csv files if that matters.
Unfortunately, I don't think there's a good all-purpose solution under the current SDK. Here are some ideas:
If you only want backup, you could just back up the whole sqlite file to the server or over wifi, but you then can't really use it with anything other than Core Data (and you might even run into trouble with iPhone-Mac compatibility, e.g. between 32-bit and 64-bit types).
A very robust solution would be to implement cloud storage with a REST API and sync the iPhone and desktop app to the server (this is what the Evernote app does, for instance), but that is obviously much more work.
You could also manually convert your data to a .csv and send that to the server or desktop, but parsing it could be problematic (and you'd have to worry about the data getting corrupted). If you did want to go that route, here is a tutorial.