Sending a binary data over the network to the my sql database - android-networking

I'm working on the application that will record the voice. I want those recordings to be stored in the external mysql database. I know that JSON works well with android and PHP that I can use to connect to DB but it works only with textual data. How can I accomplish this task? What do you recommend to use to send the data? I will appreciate for a link of the good tutorial with examples. Thanks.

There are some different examples on the internet that explain how to use HTTP requests and networking on Android to communicate with a web server. Maybe you could start by looking at some of these http://www.vogella.com/articles/AndroidNetworking/article.html http://www.ibm.com/developerworks/opensource/library/os-android-networking/
Also, take a look at some of the articles here that talk about how to write a good networking app http://developer.att.com/developer/forward.jsp?passedItemId=7200042

Related

sending MySQL database data to objective-c

I have been searching far and wide across the web, and I have not yet found a meaty tutorial on how to go about the following process:
Remote MySQL db hosted on webhost, use a webservice to send data over to iPhone, then parse data into objective-c objects for use in-app...
Why is this not documented anywhere? How do people normally deal with such a situation?
Check out this tutorial. It should give you everything you need to get started with server communication in iOS:
http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-for-an-ios-app

Tutorial to Connect iPhone app with MySQL database? (Interface Objective-C with mysql)

I am looking for a tutorial on how to make an iPhone app that fetches data from and writes data to a MySQL database. I've seen some other threads saying that I should make an abstraction layer so as not to connect directly to the database from my app, but I'm not sure of how to actually go about doing this. Does anyone know of any tutorials that involve creating an abstraction layer for a MySQL database or connecting a MySQL database to an iPhone app?
To clarify, I am looking for a secure method that wouldn't allow people to sniff out my MySQL host, username and password. It seems like the libraries that connect directly to MySQL from the iPhone all have this problem, but please correct me if I'm wrong.
This is a really good tutorial that covers how to communicate with MySQL from an iPhone app using PHP:
http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-for-an-ios-app
I know only one library, which makes possible connection from iPhone to MySQL. This is port of official MySQL C libraries created by Karl Kraft.
Author published also small portion of samples, which describes how to use this library.
UPDATE (Karl Kraft's broken link)
Instead of link above, I used an archived copy.
not up to date, but this tutorial helped me a lot:
http://codewithchris.com/iphone-app-connect-to-mysql-database/#connectiphonetomysql
Here http://blog.iosplace.com/?p=30 is a snippet that uses the original mysql client lib, and here http://www.karlkraft.com/index.php/2012/01/ is a link to a 3rd-party connector.
Here is a nice tutorial on how to connect to a database using web service layer.
From a practical perspective you could connect directly to a database from an iphone because that is a client server transaction. The problem is that you would need to expose your database server an issue that many would find very disturbing, because you would expose your server which hold your most valuable resource "your data". Of course you can implement and could be a good solution for rather small projects. But you would need to implement the layer which it would be used to connect on the iOS app, adding more complex to the matter.
Using a web service is more reliable even from the iOS developer, because there is a very extensive api for using web service, which offer great functionality (asynchronous transactions, threads management,JSON Mapping, XML Mapping) to name a few.
Use the library OHMySQL. It copes with MySQL through MySQL C API.

What is the best way to connect an iphone app to a mysql database?

I want the way with the fastest execution time. I'm not feeling comfortable of using web service because i need to create separate php pages and retrieve data as xml. If you think its good to use web service please tell me why. I want to code my database queries right on my c/objective c pages.
I've been searching for libraries. I saw this sequel pro - won't i have any problems on using this - like licensing issues? I also saw this libmysqlclient of cocoa but some say its not working well. I've also read about a library developed by Karl Kraft found here http://www.karlkraft.com/index.php/2010/06/02/mysql-and-objective-c/ but don't know if i could trust this.
I would really appreciate you help.
Definitely build a web service to act as an abstraction layer to your database. Here are some significant reasons in my opinion:
Since you want speed, you will be able to add caching when using the webservice, so you will essentially eliminate the need for identical queries to run (sometimes).
If you need to change your data model later, you just have to modify the webservice backend and don't have to update your app.
You can better control security by not exposing the database to the world, and keep it safe behind the web service.
Your database credentials should not be stored in an app. What if you needed to change those?
I strongly suggest a web service. Hope this helps.
Connect to your DB by PHP and output the result as JSON
is much better and faster then xml and less coding if use JSON Framework.
and never never try to connect to your DB from your iphone because it easy to sniff out the request from iphone.
Being safe then Sorry, keep that in mind

Getting data from remote sql table on iphone

I am a beginner at both iPhone programming and SQL, yet I have basic knowledge of them.
I am planning to do an application that would plot a graph from data taken from a database of the server of my company. I know how to plot, I know how to extract data from an sql table, but what I don't know is how to access the server.
So do I have to go through some kind of oracle-like application ?
This may seem like a very stupid question because it might not even be possible but any answer will be appreciated.
Thanks !
Go through a web service for example a PHP page that returns JSON (or XML, but JSON is easier to parse).
I can highly recommend this tutorial
Once you have your web service, you can use NSURLRequest/NSURLConnection to download the data and use a JSON framework to parse it. Or, if you're using XML you can use NSXMLParser.
See this apple code for more info on downloading using NSURLConnection.
The best way for this will be, using APIs at server end that handle the client request and perform database interaction, so transfer of data among device and server, take place through XMLs that will be secure as well as fast.
It is definitely possible to contact a server (I can't imagine what would happen without that!). What you are looking for is NSURLConnection. Have a look at the example provided by Apple.

Implement a web service or use scripts for iPhone App interaction?

I'm in the middle of working on my first native application with networking and I have a question regarding the best way for interacting with remote storage. In a perfect world I'd like to do the following.
Prompt the user for login information from the iPhone.
Verify the users credentials and connect to a MYSQL database hosted by myself.
Parse MYSQL data into a table view.
Allow the user to add or update information in the database.
I've read some similar questions posted, maybe something's lost in translation, but the two most common means I've come across are.
Create a web service for handling these requests using SOAP/REST/JSON (no experience doing this, but would like to learn if it's a better implementation)
Write PHP scripts (enough experience to get by) that will grab data username/password/requests securely from my NSURLRequest and echo the NSData as XML and parse it with an NSXMLParser.
Are there other options? Is one a better implementation over the other? (web services come up more in searches)
Thank you in advance for taking the time to read my question and possibly clearing up any confusion.
Whoa! Web Services! Oh wait, calling a PHP script that returns JSON is actually also a web service. Well, that makes things simpler :-)
Yeah, so I would go for this:
Write a PHP script that returns JSON data (many tutorials available)
Protect the PHP script by setting up 'Basic access authentication' (Apache documentation)
Tell Apache to take the user database from your mysql database
Run your service on secure (HTTPS) web server (important because basic auth is not secure)
This way you can use almost all standard components on the iPhone side. NSURLConnection will talk HTTP(S) and there are excellent open source JSON parsers for Objective-C.