Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a database/backend to android applications [closed]

Tags:

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.

like image 504
Peter Avatar asked Dec 09 '11 21:12

Peter


People also ask

How do I connect my Android apps to backend?

In Android Studio, open an existing Android application that you want to modify, or create a new one. Select the Android app module under the Project node. Then click Tools > Google Cloud Endpoints > Create App Engine Backend. In the wizard, enter the Project ID, Project Number, and API Key of your Cloud project.

Can Android app connect to MySQL database?

Android does not support MySQL out of the box. The "normal" way to access your database would be to put a Restful server in front of it and use the HTTPS protocol to connect to the Restful front end.

Does Android app have backend?

For the backend development of Android apps, developers use a form of JavaScript known as Node. js. This framework, among several other aspects, enables a developer to manage data changes from the frontend and create robust network frameworks capable of handling multiple concurrent user requests.


2 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.

like image 115
JMoy Avatar answered Oct 23 '22 21:10

JMoy


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!

like image 24
chadmaughan Avatar answered Oct 23 '22 21:10

chadmaughan