First time working with android. I’m look for a way that an android app can connect to a remote database. However, this is on a closed network with no internet connection. Just the phone and the server.
I wanted to know the best way to connect, if its through JDBC or if its possible through android’s SQLite class, or something else?
The phone is running android 2.1 and the database is a MySQL database.
Any guidance is much appreciated.
Thanks,
As long as the device is connected to the network, which would have to be via wifi, you can access a MySQL database hosted somewhere on the network just like you normally would.
My advice would be to set up a RESTful web service on the server which hosts the database. Your Android client application can communicate with this web service using HTTP requests and the web service can talk directly to the database. I’d say this is the most common approach for working with remote databases when it comes to Android.
Android Client <==> RESTful Web Service <==> MySQL DatabaseAndroid has a couple different ways to communicate with a web service:
HttpClientandHttpUrlConnection. I think the latter is generally the most preferred way nowadays.As far as I know, JDBC is unsupported for Android, and the Android SQLite API is strictly for using an embedded SQLite database.