I have an android application that is already in production. Some times, I get feedback on it and I have to fix bugs locally as it communicates with a server. I have all these set up locally so the changes I make are basically what will happen in production. In my app, I have a constants class like this one;
public class Constants{
private Constants(){}
public static final String DEV_URL = "http://dev.app.com/";
public static final String PROD_URL = "http://prod.app.com/";
}
With this kind of setting, when in development, I comment out the prod url and vice versa when publishing the app. I don't like that. I would like to have a dynamic way to have both URLs to exist but only work on the context the app is in i.e. release
or debug
. Something like:
public class Constants{
private Constants(){}
if(DEBUG){
// assuming it's debug mode
public static final String BASE_URL = "http://dev.app.com/";
}
else{
// assuming it's release mode
public static final String BASE_URL = "http://prod.app.com/";
}
}
The closest I have come to it is using this method but I can't (or have no idea) of how to get the context
. Any help or direction will be a big help.