Peter
Peter

Reputation: 5121

Creating a web/server database to be used with android app

I have experience building android applications but now I would like to start building applications that interact with some sort of web database to push and pull data.

What type of database should i set up on a remote server for my application to interact with? From what i understand I need a database on the remote server and some service that my android app can communicate with?

What can i read that will clear up how this works and how i can get started?

Upvotes: 6

Views: 6191

Answers (2)

Marcin Orlowski
Marcin Orlowski

Reputation: 75629

I strongly suggest adding web service layer between your application and database, using i.e. JSON or XML. Exposing DB directly ma be security risk and is rarely the way to go.

Upvotes: 1

user1341676
user1341676

Reputation:

The easiest (and often most flexible) combination in my opinion is PHP and MySQL. PHP as the scripting language which is called (via http) from the app, and handles all the database access. MySQL as the database. PostgreSQL is also an option for the database, of course. And if you have access to .NET, JSP or something like that, that's also an option. But a web server with Apache, PHP and MySQL is free, powerful and easy to maintain, and most/many web hosts have them.

The way it works (which is the same no matter what kind of webbased services/servers you chose), is this: - The database is installed on the server - You have a web area (on the web server) which has access to the database (this is how it will be with a typical web hotel solution) - You place your scripts (f.ex. PHP) in the web area - The web scripts access the databse, with functions for fetching and/or storing information - Your app uses httpclient or something similar to send http GET or POST requests to the PHP scripts, either sending information or asking for information, or both

It's also quite possible to write database access code directly in your app (this is very easy in Java and C#, compared to languages like C og C++). However, most hosts don't allow remote access to their database servers, so you'd most likely have to set up a database server yourself. Also, accessing the database server directly is a security risk, and I wouldn't recommend it.

As to what you can read, there's lots and lots of tutorials, howtos and concrete examples on the net. Search for "php access mysql databse", f.ex., for ideas on how to write php scripts that handles the database transaction(s). If you have a more detailed decription, I might be able to point you to something more specific.

Upvotes: 3

Related Questions