The best way to connect on MySQL from Android? - android

I want to access and replicate data between an Android app and MySQL server (both ways).
I will create a local db and a db on MySQL server.
When internet connection is enabled I will verify the db version, transfer some data to MySQL server, process there requests and get the latest database version on mobile device.
For the moment I found a JSON solution ( http://itweb-projects.com/wordpress/android-connecting-to-mysql-using-php ), but I don't know if it's the best solution. What you think?

If I were you, I wouldn't access the MySQL database directly from you android app. I'd access it through some sort of REST API. This immediately brings to mind the the SyncAdapter class and this great video from GoogleIO.

Related

Setting up a local server for SQLite database - Android

I've created a pre-made database in SQLite for an Android app I'm developing. The app should interact and pull data from the database and display it on different 'Intents'. For now I just want to set up a local server on my Windows Computer for the database.
I was wondering what is the best way of doing so? I have little to no experience with setting up local servers or anything with regards to servers.
Thanks for any help!
There is no such thing as an SQLite "server". SQLite runs locally only through libraries. Also, Android database connections can not simply connect to anything on a server.
If you need a database on a server and an Android client to manipulate the data, you need to implement some kind of client-server architecture, for example using (RESTful) WEB services or any other client-server-communication.

Android SQLite to My MySQL Web Server?

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.

Is MySQL a Network Database?

I want to insert, update, show records from an android app to a database (online) which will be installed on an android mobile.
So,my question is; which database is perfect?
MySQL
SQLite3
Any other
It's impossible to use MySQL in Android. Other SQL types neither. The best way is to use a MySQL database and get the information via PHP. Encode it to JSON in PHP. You can get the Web page in Android and decode it in Android.
Is mysql db is network database
MySQL (like many other database servers including Postgres and Oracle) can be accessed either through a local socket or via TCP/IP. (You also mentioned SQLite, this is a file based database and does not have a network server AFAIK).
There may be libraries for Android that implement a MySQL client, but a few minutes with Google didn't turn any up for me.
Generally speaking, network access to MySQL should be limited to private networks and not end clients anyway.
If you want to access a database from a client application over a network, you are usually better off by building an HTTP based API (preferably one that is RESTful) and letting the client software connect to that. This gives you more control over what clients are allowed to do with the database.
You can build such an API in just about any language you like. If you are working with Android, you might prefer Java. My preference would be Perl. Python is a good option, etc, etc.
which database is perfect?
Nothing is perfect. Giving a recommendation for a specific database would be drifting into "Not Constructive" territory, even if you were more specific about your requirements.

How to get details from mysql database for android?

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

How to connect android to MySql database server?

In my project, I have to connect an Android mobile phone to a remote MySQL database server, to insert data to the database and get the data back later.
However, it seems that Android OS only supports the SQLLite database that works LOCALLY inside the phone.
Does anyone know how to connect an Android phone to a remote MySQL (or MSSQL, or Oracle) database server ?
Thank you!
You will have to access the database using some sort of Remote Method Invocation (RMI).
My personal recommendation is to create a RESTful HTTP interface to your MySQL database on the server. This may be a bit more work, but is preferred for its ease of use and compatibility with any system (that can make an HTTP request that is).
Essentially, you should create HTTP endpoints to Create, Read, Update, Delete (CRUD) data from your MySQL database on your server. Your Android client would then make calls to these HTTP endpoints to perform the corresponding CRUD operations. Of course you do not need to do the typical CRUD operations, you can make your endpoints interact with the database however you wish.
Like I said, a big advantage to this is how extensible it is. You can create another client, on another system, in another language, and all you need to do is make the proper HTTP call.
try using Jdbc... for more read this http://developer.android.com/reference/java/sql/package-summary.html

Categories

Resources