DEV Community

JavaOneWorld
JavaOneWorld

Posted on

How to manage multiple END_POINTS or BASE_URL when developing android app.

In this article, we learn how to manage multiple End_Points/Base_url/Server_url for the project.
As every developer knows that there is multiple URL in their single project,
for example one for development, one for production, one for testing, and many more.

n most of the case minimum, two URL is a must.
one for production and one for development.

so how to manage multiple URLs,

1- if I am installing an app in debug mode( development), then I want the development URL, which will interact with my local DB.
2- and if I'm generating release mode .apk file then I want production URL which will interact with the server.

the first and very known pattern is to define both URLs with the same name, and when need to debug URL, "uncomment the test/debug end_point and comment the production URL " and when the need for production URL do the vice-versa.

is it a good way, a good programming approach?
no never.

everyone knows that this task is very hectic.

here is the best way to handle multiple URLs.

1- look in your app-level grade, you will find buildTypes{}.
2- customize your build type like this.

Look here to get how to code to achieve this.

https://www.javaoneworld.com/2020/06/how-to-manage-multiple-url-end-points-base-url-android.html

Top comments (0)