I have database on a server, and I have the username and password to access to this server. My question is: how can my android app read a table from a database on a server? I know, this question was asked, but I did not found any code or any answer that explain that detailed.
Asked
Active
Viewed 7,047 times
0
-
You need to write a web server that exposes the data. – SLaks Jun 01 '15 at 15:28
-
2There are actually several ways of doing this, it would help if you wrote down what you tried to do and where it didn't work out for you. – Razgriz Jun 01 '15 at 15:29
-
@SLaks Can you give me an exmaple or any tutorial? or in which language should i write that? and how? – user3625605 Jun 01 '15 at 15:31
-
@Razgriz I need only one column from this database, I have all things(hostname, username, password and server) but I do not how to use that or how to write a program that does that: – user3625605 Jun 01 '15 at 15:33
1 Answers
2
Basically you need a Web Service that read/write into your DB. Android then read the data through JSONObject and parser.
Direct connection through JDBC is insecure.
Below is tutorial on How Android connect to mySql on server
- http://www.tutorialspoint.com/android/android_php_mysql.htm
- http://www.helloandroid.com/tutorials/connecting-mysql-database
- http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
You may also take a look on this thread

Community
- 1
- 1

stuckedunderflow
- 3,551
- 8
- 46
- 63
-
thanx, is JDBC easier? If yes, then can you give me tutorials of that, because the security is at the moment not very important for me. I need to write my program only in java, I do not need php. – user3625605 Jun 01 '15 at 17:09
-
It is doable https://capdroid.wordpress.com/2012/07/10/configuring-and-accessing-mysql-jdbc-driver-on-android-application/ BUT not very recommended. Look at this http://stackoverflow.com/questions/12233145/connecting-to-mysql-from-android-with-jdbc – stuckedunderflow Jun 02 '15 at 03:39