how can I use same sqlite data on more than one iPhones - iphone

I have implemented an App which uses SQLite database, now if I run the App on a device then the database exist in that device only, now I want to use the same data on more than one device, can I do that?

You could use iCloud to copy your DB between devices. There are three ways you could do this.
Implement all the file presenter coordination code by hand. This would be difficult, but your existing read/write code would stay the same.
Wrap your DB in a UIDocument. This would be much easier, but your existing code to save and load your sqlite file would need to change. Conflicts would be resolved at a per-database level.
Port your DB code to use Core Data and use a UIManagedDocument. Your entire codebase would change, but conflicts would be resolved at a much lower level.
I heartily recommend Ray Wenderlich's tutorial series on iCloud, Beginning iCloud and iCloud and UIDocument: Beyond the basics

You need a Database Server to store your data & a Web service which should have the logic to store/fetch data from the Database-Server & Back to Database-Server. You can communicate between the DataBase Server & the Android Device using that Web Service.
On Android side you can use KSoap to consume the web service. See this example here.

Related

Stream coredata to remote REST end-point

There are several apps that I use on my Mac that store their data in core data. I can see the data I want in CoreDataPro. I want that data - specifically I want to send changes in that to some remote end points (such as Zapier, or some other REST service).
I was thinking of piggybacking something like RestKit - such that I provide a configuration file saying where the app is and what end points the data needs sending to. I need only to scrape the data and send to REST, not a two-way sync.
I'd prefer a utility that I could configure rather than having to code a Mac application.
I noted http://nshipster.com/core-data-libraries-and-utilities/ - RestKit still seemed the most capable, but in https://github.com/RestKit/RestKit/issues/1748 I was advised that coredata projects should only be opened by a single application at a time, and really RestKit is designed for baking into the source app (rather than for database scraping and sending).
What approach would you take?
I also noted:
http://www.raywenderlich.com/15916/how-to-synchronize-core-data-with-a-web-service-part-1
Thanks, Martin.
First, Core Data is an object store in memory. What is written to disk from Core Data can be in one of several formats. One of those formats happens to be SQLite. If the application is writing to SQLite then it is possible to sample that same file and push it somewhere else.
However, each application will have its own data structure so you would need to be flexible in the structure you are handling.
RestKit has no value in this situation as you are just translating objects into JSON and pushing them to a server. The built in frameworks do that just fine.
There is no utility to do this at this time. You would need to write it yourself or hire someone to write it.
If I were going to do something like this, I would write it using Core Data itself interrogate the model from the application that wrote the data in the first place and then translate the database into JSON and push it. You won't be able to tell what is new vs. old so the server will need to sort that out.
Another option, since you can't diff anyway, is to just push the sqlite file to the server and let the server parse through it.
Other answers might include:
use a middleware platform e.g. using rssbus.com (only) sqlite connections are free to send the events
as my target system (http://easy-insight.com) actually has a transmitter that sends new records it sees from MySQL abd PostgreSQL, I could https://dba.stackexchange.com/questions/2510/tools-to-migrate-from-sqlite-to-postgresql or use an ETL such as http://www.easyfrom.net (I did ask the vendor for SQLite support a long time ago, but SQLite is just not a priority for them).
I'm wondering whether a good answer (where good excludes Objective-C and includes languages that I do know, such as - to a limited extent - Ruby) is to use MacRuby and its Core Data libraries.
Core Data seemingly can be exposed as an Active Record. https://www.google.com/search?q=macruby+coredata , notably http://www.spacevatican.org/2012/1/26/seeding-coredata-databases-with-ruby/
However, MacRuby seems to have faded - https://github.com/MacRuby/MacRuby/issues/231 - it won't even compile on Mavericks.

How to Learn/Create a Database iPhone App?

I have a rather simple idea for an iPhone app. What I need to accomplish:
Allow login of users (which means I'll have to store usernames, passwords, and other account info).
Allow users to submit strings that other users can view.
Attributes attached to each string that must be tracked (i.e. "votes, views, comments, etc.).
As such, I assume I'll need to start learning about databases and working between a server and client. I've gotten my feet wet in OSX/iOS programming (specifically Objective-C) before. I want to learn how one can accomplish a data-based application and the needs I listed above.
I've done some light research and discovered something called SQLite (free and open-source is always good). Is this the right path to achieve what I want to do? I'm a total "noob" when it comes to this field of server/client/data "stuff".
Your help is greatly appreciated.
SQLLite is more like a local database. Really, the database that you will use is unimportant. It sounds like a project with webservices. Inside your webservices, you might connect to a Microsoft SQL Server or anything you want.
I think you should study how to setup a webservice that can be accessed in your code. Webservices is not an Objective-C topic, it applies to any platform. Your project is more like a web development project.
You can save user's credentials in keychain.
#Kinderchocolate is right about introducing database into your project.
It hears about a app which need transmitting data among clients.It means your need server database and local database.
For server database,I recommend you to use Parse.Parse is a platform which provide a convenient way to use their server database with Objective-c in your app.This tool will save many times and energy(it's not necessary to learn PHP,Apache,Mysql).Parse is not free of course,but it has a free period and enough for you to examine your idea.
Here's Parse!.
For local database,I recommend you to use Core Data,Which is provided by XCode.Core data is so strong to meet your need.You can find a way to use Core Data in many books.
Go try Firebase for database in the cloud. (On the server). In Swift 4 there is complete support for Firebase and SQLite

Storing and retrieving data from MySQL or other databases

I've been researching now for couple of days about this matter but with no luck.
I am learning iOS development with the plan of developing iPhone app mainly. Now this app will mimic the behaviour of my PHP site.
The question: Can I interact from my iPhone app directly with my tables to load and/or insert new data? if not mySQL then which database is used to host the data for CRUD operations? JSON objects? if yes, then how?
As you can see I am really unaware of the way and hope that some light should be shed on storing and retreving data from existing database or what I need to host new database to use with iPhone.
The "best" and easiest way (for me anyway) is to use CoreData.
CoreData is a data management system. You set up some objects and relationships in it and then interact with those (use fetch requests to retrieve them and stuff).
CoreData then manages a datastore (most often a SQLite DB) which it uses to store the objects and relationships etc...
Using CoreData removes the necessity of a DBA and a lot of the complex DB logic and stuff.
A good tutorial to look at is this one...
http://mobile.tutsplus.com/tutorials/iphone/iphone-core-data/
I bought this book though...
http://www.amazon.co.uk/Pro-Core-Data-Professional-Apress/dp/1430236566/ref=sr_1_2?s=books&ie=UTF8&qid=1358773284&sr=1-2
and found it extremely useful for everything from starting out to the more advanced stuff.
When used properly, CoreData makes it VERY easy to use and manipulate persistent data.
YES, You can interact from your iPhone app directly with your tables to load and/or insert new data; Check the next tutorial - interact with your MySQL/PHP server http://www.scott-sherwood.com/ios-5-uistoryboards-a-practical-example/
CoreData is good but limits to access to just iDevices.
I use couchdb, means a copy is stored in the cloud with auto syncing between cloud and devices allowing for web updates and also Android

SQLite vs. Core Data: Where do I begin?

I have been reading and learning a lot about sqlite & core data for the past few days, and I just can't grasp which method is better for my app? I would prefer to use Core Data because I worked through the Stanford courses on it, and feel like I understand that better. But it also seems like it's not possible to do what I want to do with my app by just using Core Data.
Basically, I'm attempting to mock the system that Twitter uses. What I mean is that users sign up, create a profile, and when they post things, their friends see it in a feed.
Is it possible to create a system like this among a large user base by simply using Core Data? Or do I need to use both Core Data & SQLite?
Thanks!
To create a shared system like that, you will need a service in the cloud that the devices connect to.
The devices would have to pull data from the cloud service with local storage - especially if you want the data to be visible or usable while they are disconnected. Local storage can also provide better performance.
Concerning CoreData vs SqlLite - CoreData is for iOS only but it gets you going faster and keeps you productive with a nice designer and a nice set of APIs. SqlLite is much lower level giving you direct sql control over your storage and queries. It's certainly possible to write local storage for something like your describing in sqlite or core data.
The other consideration is whether you want to share that storage code (schema/queries/etc...) across other platforms eventually like Windows Phone, Android, etc... Sqllite is cross platform and works great on devices and desktops. In some scenarios, the store it self (the data file) could be portable across devices platforms.
Depending on the complexity of your storage and whether you want to share some of that across devices or just code separately is a consideration. There is no one right answer here.

Can Core Data use a Web Service as a persistence store?

I'm working on an app that uses Core Data, and I'd like to be able to code it in a way that it can use a local SQLite store or a web-based store (with an XML or JSON response schema).
Is it possible to use the exact same code for the Core Data stuff and just select the appropriate persistence store based on a user's preference?
Look at the WWDC video "Building a server-driven user experience".
You can connect to a remote store via a URL but that doesn't sound like what you want as that would support only one store for every remote user.
Really, all you need to do is setup a regular SQLite store and then add a little code to send changes to the server via the chosen method. Then you could turn the server connection on and off as needed.
That would be simplest as long as you don't have a requirement that no data be persisted on the device itself.
In theory, yes. However you would probably wanna cache the data locally in case of network issues etc.
Take a look at this project https://github.com/AFNetworking/AFIncrementalStore which doesn't really implement a Web Service backed NSPersistenceStore, but it does try to achieve what you have in mind.