Is it possible to use a .properties
file in android from assets in release and other when I do debug in android studio?
I'm using gradle, but I don't have any idea how can I do it this.
Thanks
Is it possible to use a .properties
file in android from assets in release and other when I do debug in android studio?
I'm using gradle, but I don't have any idea how can I do it this.
Thanks
I suggest you to name your files this way:
file_debug.properties => debug file
file.properties => release file
and in your code do this:
final String mode = isDebugMode() ? "_debug" : "";
final String suffix = mode + ".properties";
String fileName = "file" + suffix; //either file_debug.properties or file.properties
private boolean isDebugMode() {
return android.os.Debug.isDebuggerConnected(); //is being debugged via ADB
// or
//return 0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE); //can be debugged, but maybe not at the moment
}
You can check wheter you are in debug or release and load your necessary file from assets. Check this post How to check programmatically whether app is running in debug mode or not?
except you can detect the debug mode in your code and choose which branch to go, you also can custom you ant build process to change the properties file like pre_compile.
we now have an configure file when developing, and we have an isolated build machine to build release version, and in the build machine, we change the property file to the release version.