-2

I'm learning Android development and mostly to retrieve data from the server side databases,I use Async tasks, to obtain data from PHP and MySQL.

I want to know whether is it possible to connect the android application directly to the MySQL database.What would be the adverse effects of doing so? And is there any example on how to perform CRUD operations using such direct MySQL connection?

halfer
  • 19,824
  • 17
  • 99
  • 186
Spark
  • 47
  • 5
  • Normally you use a on-device SQLite DB with Android and that is really easy to use and not totally different from MySQL. – juergen d Sep 17 '16 at 15:53
  • I need to have a common database for all the users,so SQLite is not possible. – Spark Sep 17 '16 at 15:55
  • Just google "stackoverflow android xyz" fill in xyz. http://stackoverflow.com/q/36063130 – Drew Sep 17 '16 at 16:01

2 Answers2

1

According to: https://developer.android.com/reference/android/os/NetworkOnMainThreadException.html you can't networking in main thread and according to:

Direct connection to MySQL in Android is not recommend/not possible.

Community
  • 1
  • 1
1

If you anytime feel like using different Networking Calls. Use Volley, it is fast and better than Asynctask request. As per your question network calls are not possible on Main UI.

Try reading more about Volley which google introduced in 2013. A very good MySQL CRUD example on my blog. here

W4R10CK
  • 5,502
  • 2
  • 19
  • 30