title: Saving the API Key in gradle.properties
body: <p>I am new to android and working on a project where I see that the API key that I got is saved in <code>gradle.properties</code> as :</p>
  
  <p><code>MyOpenWeatherMapApiKey="1c3ae96f93a0094e8a7chsjdgfid04aed3f10"</code></p>
  
  <p>And then in <code>build.gradle(module:app)</code> I am adding the following lines : </p>
  
  <pre><code>buildTypes.each {
              it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', MyOpenWeatherMapApiKey
        }
  </code></pre>
  
  <p>So, in my main program I am accessing the data using this api whose URL is got by this piece of code :</p>
  
  <pre><code>final String FORECAST_BASE_URL = "http://api.openweathermap.org/data/2.5/forecast/daily?";
              final String QUERY_PARAM = "q";
              final String FORMAT_PARAM = "mode";
              final String UNITS_PARAM = "units";
              final String DAYS_PARAM = "cnt";
              final String APPID_PARAM = "APPID";
              Uri builtUri = Uri.parse(FORECAST_BASE_URL).buildUpon()
                      .appendQueryParameter(QUERY_PARAM, params[0])
                      .appendQueryParameter(FORMAT_PARAM, format)
                      .appendQueryParameter(UNITS_PARAM, units)
                      .appendQueryParameter(DAYS_PARAM, Integer.toString(numDays))
                      .appendQueryParameter(APPID_PARAM, BuildConfig.OPEN_WEATHER_MAP_API_KEY)
                      .build();
              URL url = new URL(builtUri.toString());
  </code></pre>
  
  <p>So, my question is that why taking all the tension of doing changes to store the appid in the gradle part. Can't we access directly in the main program only ?</p>
  
  <p>And the second part of my question is what is actually happening in the gradle part especially with the <code>buildTypes.each{}</code> block ?</p>