Adding a database/backend to android applications

So I've been writing small android applications and want to start writing bigger apps that have the ability to allow users to create accounts, allow me to store their account data online in some sort of database and really just adding some sort of functionality that would require some sort of backend.

I'm new to programming and am starting with Java/Android. Where should I start to learn about this stuff? Would this be a database I would need? What type(s) are popular or good to learn/use?

I read about https://www.parse.com and it looks interesting and easy to use but I don't want learn something that isn't a standard or that I would only be able to use with their client.

Answers


I have never used Parse before, but it seems like an easy way for you to not worry about writing all the server-side code, the downside is: it costs money the more you want to use it and you're also tied into their API and way of doing things. If you do use Parse, you'll only have to worry about writing code for your Android app to interact with Parse. You can see their documentation for details on that.

The cheaper route involves a bit more work. You'll need a

  • Server to host the backend

  • Server-side language (i.e. Java, PHP, Python.. list goes on) to control/handle requests from your Android application.

  • A database (mySQL, PostgreSQL, Oracle, etc.) setup with the schemas you want (i.e. a User table)

The general flow is: your Droid app would make a request to http://yourserver.com/BackendFunction with parameters to that function. Your server side scripting language would do the backend work (i.e. adding a user to the database). The server responds back to your application with some info (usually JSON or XML, whatever you choose) with relevant information, and your app displays a nice view of that info.

You'll need to research how to query databases with whatever server-side language & database you're using and how to send/handle HTTP requests & responses.


You're right that you'll need some sort of datastore on the server side to store your data. It could be a traditional RDBMS database (mysql or postgresql), or something newer like a noSQL solution (mongodb, riak, couchdb). Parse looks cool, but I've never tried it.

For my recent Android project, I've been using Couchbase's Android libraries (http://www.couchbase.org) with ektorp (http://www.ektorp.org) that allow me to replicate to a server-side CouchDB instance. It's been great for a number of reasons:

  • uses HTTP to send data by default
  • sends the data in a JSON format (no converting - binding/serializing)
  • simple 'replicate' command in ektorp to pull/push data between client and server

Also, based on the datastore you choose, you'll still need to decide on a few things:

  • What format will you send the data to the server? I'd recommend JSON. Other options are XML or YML.
  • How will you convert that data on the client for transport? The jackson-json library is awesome if you choose JSON.
  • Do you need a middle-tier to protect and/or translate your chosen data format? You might want to check out Spring MVC for building restful based webservices if you require a middle-tier.

It might seem daunting (server-side stuff tends to feel that way sometimes), but keep at it and you'll get it!


Need Your Help

How to debug a basic node.js application (not http) on windows

node.js node-inspector

I know how to debug http applications using node-inspector and iisnode. But can I use node-inspector to debug a non http node application, on windows?

What is the difference between Shell, Kernel and API

api shell operating-system kernel

I want to understand how this applies to an operating system and also to those things that are not infact operating systems. I can't understand the difference between the three and their essence. A...