I'm creating an app that will have a Lite and a Full version of it, one being free and the other having a small fee. Since I don't want to have to distinct projects to avoid updating errors (like updating a module in one version only) I set up a boolean in my Application class.
I was wondering how can I determine the value of that boolean with information from the app. I know I can create app with different Flavors and Build Types but I'm kind of lost in all that. Can you help?
Thanks!
I assume you're using Gradle and AndroidStudio, right? You can create BuildConfig values for each flavor and/or buildType:
Goto your app/build.gradle file
If you prefer to put your variable at
a. buildType:
buildTypes {
debug {
versionNameSuffix "-beta"
buildConfigField "Boolean", "PAYED", "false"
}
}
b. flavor
productFlavors {
premium {
buildConfigField "Boolean", "PAYED", "true"
}
}
And than, after a sync & build you can access those variables in your code depending on build/flavor you've chosen:
if (BuildConfig.PAYED) {
// Do your stuff
...
}