I need to print logs in my application only while I am developing it. So is there a way like a boolean which will decide if my app is in a certain mode , and only allows to print log then? This will save my time from deleting logs every time I prepare for a signed build.
I tried solutions like:
boolean isDebuggable = 0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE);
and:
if (BuildConfig.DEBUG) {
// do something for a debug build
}`
They don't work like I want it to.
Thank you.
Just use a static variable debug
like this:
if(debug){
//do something
}
And set debug
to false
when you release the apk file.
Or create your own custom log method:
public static void logInfo(String tag, String msg){
if(DEBUG){
Log.i(tag,msg);
}
}