variables in the local.properties file in android studio

local.properties file

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Aug 22 10:54:33 BST 2016
sdk.dir=C\:\\Users\\MrDevMonk\\AppData\\Local\\Android\\Sdk
addsuffix=true

and then in the app gradle you can access it using the Properties class

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def addsuffix = properties.getProperty('addsuffix')

and you can also add it in the buildConfigField

buildConfigField "boolean", "ADD_SUFFIX", addsuffix

and from your hava classes you can access it:

BuildConfig.ADD_SUFFIX

Leave a Reply

Your email address will not be published. Required fields are marked *