Ways to make content dynamic in Android Applications.

When i develop android application, i keep one thing in my mind “Not to hard code even a single piece of information.” and that is really a good practice. We have many ways to fetch data in Android app instead of hard coding and that depends upon your app.

  1. JSON File in your app : In Resource folder you can place one JSON (Preferred) or maybe XML file that contains all the configurations of your Android App. When you android app executes you can read that JSON file create Objects and use that object to render your application. But this has some limitations, whenever you want to change any piece of information you need to go to your Android code, change your JSON file content and re create new APK and distribute that. This i am using when i want to make my app dynamic, means if i am creating one app for Delhi Tourism that has all the information about Delhi, i can use JSON with Delhi Info and some day i planned to make an App for J&K Tourism i just need to update the JSON file and re compile my code and it works. This is just to reduce coding time.
  2. Local Storage in Mobile Phones : In Android we have SQLite Database which is the Light version of MySQL and its free to use. You can create Tables, run CRUD operations easily using simple SQL Queries. This is used to store information about your user or maybe his actions. Just like in Whatsapp we have all the information stored in our own device in databases. But remember this will make you android app standalone, you can’t access content across devices.
  3. Server : Mostly used solution is having a server where you have deployed application that is exposing Web Services. Server will have a database connected with that and on Server you can write your piece of code in your favorite programming language, it can be Java, PHP, .Net etc. And what this code will do ? It accepts the HTTP Request from mobile devices along with the data to store or retrieve, process the request using database and returns you the desired output. And that output you can render in your application. This is used when we want to access the data across devices like today you logged in from your phone and added some content and tomorrow you logged in with your account from your friend’s phone you can see the same information you have added from your phone. One Server and multiple Devices. But this option may cost you Server Cost, Server Side coding cost.

Be the first to comment

Leave a Reply

Your email address will not be published.


*