i am new to android development. i am developing an android app for a university management system. Can i establish connection with database like postgreSQL or MySQL in android.?If yes how?. Also, Can some one provide me with a link to find source code of similar applications
-
usually, such a DB will be installed on a server, and said server will expose some parts of the data through an interface (usually webservice, often RESTful ones). The actual DBMS behind it is rather irrelevant. could be plain text files, whatever flavor of SQL, Mongo ...njzk2– njzk22014-04-25 16:40:47 +00:00Commented Apr 25, 2014 at 16:40
2 Answers
You have three main choices:
Direct connection to database
You can connect the devices directly to your database with JDBC driver.
http://www.basic4ppc.com/android/forum/threads/connect-android-to-mysql-database-tutorial.8339/
This is not your best choice if you want to maximize the security of your system.
Web services
You could deploy a REST service on a server that connects to your database, and the android app should communicate with this service if you want to make any operation (read, write, update, delete) in your database.
You have a lot of tutorials about how to deploy REST web services in your fav language/framework.
DJANGO = http://www.django-rest-framework.org/tutorial/1-serialization
NODE = https://github.com/mcavage/node-restify
RAILS = http://old.thoughtsincomputation.com/posts/understanding-rest-in-rails-3
This is the most commonly used stack for android apps that needs database. Next, you have a nice tutorial here for how to connect to REST service via Android:
Local database
Maybe is not what you want, but you can access to local SQLite database in your app. You can deploy your apk with the database asset inside or just download the database file from a server
Hope it helps!
Comments
Android has an inbuilt sqlite database that you can use within your app. You can also access virtually any other database system via an API.Have a look at this link http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/ and http://www.tutorialspoint.com/android/android_php_mysql.htm