Web Services vs Direct Database Access for Android Apps

androiddatabaseweb services

I searched on the web how to access in an efficient manner to a central database at a remote location and I met suggestions to use web services instead direct access (i.e. JDBC etc ) to a database.I wonder the reason of that and any other suggestions.

Best Answer

Adding a web service layer gives you an opportunity to make your client more lightweight, both in terms of the required CPU power and the bandwidth used during the processing. Both factors are extremely important to end-users:

  • Using less CPU increases the battery life,
  • Using less bandwidth reduces monthly payments for users with metered plans

By introducing a web application layer you move the bulk of the processing from a hand-held mobile low-power, low bandwidth, low-memory client to a plugged-in, high-power high-bandwidth, server that has more memory than it needs - an environment where processing and communications cost a fraction of what they cost on a client.

But wait, there is something in it for you as well: by splitting the system you get more control over your business rules, the structure of your database, and the versions of what's out there. Once you let a mobile client connect directly to the database, your design is "married" to that database structure: almost any change would break backward compatibility to a client that may be reluctant to upgrade his app.

In contrast, adding a web service in between lets you evolve the interface to mobile clients in more manageable ways: for example, you could keep the old interface in place, add a new one that works "in parallel" with it, and then entirely restructure your database without breaking a single client.

If you follow some pretty basic design principles while designing your web service, you could also get significant benefits by reusing mature server-side infrastructure that has been put in place: for example, you can get cache and proxy services for free.

Finally, this will open the door to other developers exposing your application to platforms that you could not service yourself, ultimately playing to your company's advantage.

Related Topic