I have a script in java that works like a crawler and saves data in MySql DB. What i want to do is build a Mobile App(Andriod/ios) which will connect to mysql database retrieve results and just show it to the user.
What is the best approach to this ? I tried to use Flex UI with PHP as my server client but was hoping to know if there is a better solution ?
The fastest would be to make android fetch a page in XML, typically on the server and display its contents(If displaying contets is your desired result).
else
You need to implement a script on your server, your POST interacts with that script and inturn that script works with your database.
A typical scenario will be:
Java HTTP POST ~~~> PHP ~~~~> MySql.
PHP will as well help you encode the result in JSON and post it back to your client.
Try using jdbc or jtds library to connect android app with mysql
I used jdts library for connecting mssql db using android app.
http://jtds.sourceforge.net
For mysql jdbc might work
Related
I'm making an application, I already have a website nodejs with expressjs framework and mysql database. how to process the input, update and delete data from android to mysql without using php server side? if anyone has ever made before? thank you
Basicly that's what the server side code is doing!
Handling all the data and requests between the two (android app & the relational database)
Any attempt to not use the PhP or any type of language for that matter would cause only to iconically change some data from the app!
But that's not the case since you want to alter also the database as you clearly mention!
As for the how: The only way to use the data transfer to the app is by the use of json packets!
A exchange should be made between the app and the database "through" the server side php code and they should exchange json files with data!
Then your problem is solved.
I have been learning SQLite on Android and have done some tutorials on how to use it.
There is a question that I want to ask.
Is there a way to make my app connect to my MySQL database in a remote web server of mine so that it can read data and also write data to the database?
From what I've researched, SQLite cannot be used remotely and I would need some kind of Web service in between?
It's not easy to create a connection to MySQL from Android, if it's not impossible. With that, it's also not safe if for example someone decompiles your app they have access to your whole MySQL database if you don't limit it enough.
For those reasons, you can better use a (for example) PHP webservice to which the Android application sends all their requests. An example is available at http://www.helloandroid.com/tutorials/connecting-mysql-database.
I also suggest you use Android Asynchronous Http Client so you don't have to deal with connectivity issues and AsyncTasks yourself.
You can refer to this tutorial but you do need a web-server for it.
Request mechanism
Android App ----> webserver ------> database (mysql)
Respond mechanism
Android App <---- webserver <------ database (mysql)
Android App will use JSON or other to get the data and display it
You have to use Sqlite database and web Services both. First you have to save the data in local database i.e. SQLite database and then send this data to your server using web services and vice versa.
this link for web services
and this link for SQlite will help you understand.
Thanks.
I am trying to figure out how to populate a Spinner (eventually a whole form of spinners) with data taken from a remote MySQL database. I have read hundreds of examples and tried to replicate them all but to no avail.
I have been working with this example from http://www.mickyjay.co.uk/blog/?p=679
I was never able to get it to work but it seems the most promising out of the lot.
QUESTIONS:
1) Do I need to use a JDBC bridge to connect to the server ? (I was reading that Android does not come with a library to connect to a remote server).
2) I am not looking for someone to do this for me. If anyone has any links to resources that are CLEAR and well documented. I would very much appreciate it.
Since you have MySql database it's good to use PHP to connect to database and send result back to android using JSON response. Android and PHP both support JSON. You can then read JSON and process data as you want in android side. You use HTTP request to run php script. Take a look at this tutorail that shows how to use android, PHP and MySql all together http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/
I want to connect my android application to an external mySQL database and I found that I have to use web service to achieve that using php code.
but I used to use java, Is there in java any equivalent to php code??
It depends on how the server side is implemented. Both php and java can implement the server side code and access MYSQL DB. Through your android client you dont' have to be concerned about the server side (If the server is not yours and just responds to your queries) , you have to make HTTP request POST or GET to achieve it.
How can I connect MySQL and Android?
I have MySQL db in remote I want get the values from that database and display those content in Androidlist view. I have tried many web service samples, but I have met some problems.
I have tried this using json and php from this link http://blog.sptechnolab.com/2011/02/10/android/android-connecting-to-mysql-using-php/ , but my app quits
There is no JDBC driver for android / MySQL. So you can't connect to your database as a desktop application or a web server would.
You then have to write a small interface, typically a web server to make your mysql data available, and then write a small android client, usually parsing xml stuff from your server.
That's the way to go, the very big picture, but your question is vast and fuzzy, that's the best answer I can give you.
There are various way to access mysql database from android.
You can access data from web services for ksoap2-android lib is good fro that. Click for web services example web-services example
You can also use Http connection or socket programming.
This have been repeatedly in SO, here a i leave you with some samples
SO
Connect MySQL database from Android
Get data to android app from mysql server
How to connect to a MySQL Database from an Android App?
android remote database connection trouble
mysql db connection
Connect MySQL database from Android
And also in other places,
AndDev
[TUTORIAL] Connecting to MySQL database
HELP with a Tutorial for connection using MySql
More
But wait there is more :D, on google